24 Jan 2013

Querying values in XML field - MS SQL 2008

In MS SQL 2008, you can use these script to query a value from xml column.

Check existence. This returns 1 if there is an element in xml
[column].exist('//element-name') = 1

Get element.
[column].query('//element-name')

Get value of element. You can define the type of value.
[column].value('(//element-name)[1]','date')

0 comments:

Post a Comment