Monday, March 30, 2009

XML Insertion

We can use New way of selecting Nodes from XMl by using following:

Declare @xmlData xml

SET @xmlData='

';

Declare @temp as table (id int, Name varchar(50))

Insert into @temp

SELECT T.item.value('@id', 'int') as [id], T.item.value('@first_name', 'varchar(50)') as [Name]

FROM @xmlData.nodes('/cis/user') AS T(item)

where T.item.value('@id', 'int')=57

Here no need of using OPENXML() method.

Please visit the following link for details:

http://www.sommarskog.se/arrays-in-sql-2005.html

http://www.sommarskog.se/share_data.html

No comments: