1 2 3 4 5 6 7 8 |
DECLARE @x XML SET @x = '<row><id>123</id><name>test</name></row><row><id>456</id><name>test2</name></row>' SELECT t.c.value('id[1]', 'varchar(50)') AS a, t.c.value('name[1]', 'varchar(50)') AS b FROM @X.nodes('//row') AS t(c) |
1 2 3 4 5 6 7 8 |
DECLARE @x XML SET @x = '<row id="123" name="test" /><row id="456" name="test2" />' SELECT t.c.value('@id', 'varchar(50)') AS a, t.c.value('@name', 'varchar(50)') AS b FROM @X.nodes('//row') AS t(c) |
No comments:
Post a Comment