[XML 插入]xml 多列插入表变量
DECLARE @t Table (c1 int,c2 int) DECLARE @x XML SET @x = CONVERT(XML, '<items> <item c1="' + REPLACE(REPLACE('1-4,2-5,3-6', ',', '"/><item c1="'),'-','" c2="') + '"/> </items>') INSERT INTO @t SELECT x.item.value('@c1[1]', 'INT'), x.item.value('@c2[1]', 'INT') FROM @x.nodes('//items/item') AS x(item) SELECT * FROM @t
DECLARE @t Table (c1 int) DECLARE @x XML SET @x = CONVERT(XML, '<items> <item c1="' + REPLACE('1,2,3', ',', '"/><item c1="') + '"/> </items>') INSERT INTO @t SELECT x.item.value('@c1[1]', 'INT') FROM @x.nodes('//items/item') AS x(item) SELECT * FROM @t
真正的大师永远怀着一颗学徒的心。

浙公网安备 33010602011771号