Say I have the following situation (for demonstration). The simple table content is converted to an XML value and sent via Service Broker to another SQL server where the res
CREATE TABLE tab (a int, b int, c int);
GO
INSERT INTO tab (a, b, c) VALUES (1, 11, 111);
INSERT INTO tab (a, b, c) VALUES (2, 22, 222);
INSERT INTO tab (a, b, c) VALUES (3, 33, 333);
INSERT INTO tab (a, b, c) VALUES (4, 44, 444);
GO
CREATE TABLE tab_destination (a int, b int, c int);
go
declare @x xml = (SELECT * FROM tab FOR XML RAW, TYPE);
insert into tab_destination (a, b, c)
select
x.value('@a', 'int'),
x.value('@c', 'int'),
x.value('@b', 'int')
from @x.nodes('//row') t(x);
GO
select * from tab_destination;
go
Time to read xml Data Type Methods