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 result of the SELECT is to be stored in the non-XML form (i.e. usual, simple database table). Let's try:
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
SELECT * FROM tab FOR XML RAW, TYPE;
GO
When capturing the value to the message, it looks like:
<row a="1" b="11" c="111" />
<row a="2" b="22" c="222" />
<row a="3" b="33" c="333" />
<row a="4" b="44" c="444" />
i.e. single multiline string. Say, I create the exactly same table structure at the destination machine:
CREATE TABLE tab_destination (a int, b int, c int);
What is the best way to extract the rows from the @msg, and how to put them to the destination table?
Thanks, Petr