通过SQL Server 2005中的XML值进行查询

时间:2022-01-23 01:35:46

Let's say I have a column in a table where the datatype is XML. I have a specific value I want query for in an xml tag that is unique(no repeating) in the XML. How do I do this?

假设我在表中有一个列,其中的数据类型是XML。我希望在xml标记中查询一个特定的值,该值在xml中是惟一的(不重复)。我该怎么做呢?

Something like:

喜欢的东西:

select * from MyTable 
 where XMLColumn.TagImLookingAt.Value = @QueryValue

1 个解决方案

#1


5  

Use:

使用:

WHERE xmlcolumn.value('(/path/to/tag)[1]', 'int') = @QueryValue

Change the data type to whatever is appropriate.

将数据类型更改为适当的类型。

For more info, see the documentation - specifically the methods available when dealing with the XML data type...

有关更多信息,请参见文档——特别是处理XML数据类型时可用的方法……

#1


5  

Use:

使用:

WHERE xmlcolumn.value('(/path/to/tag)[1]', 'int') = @QueryValue

Change the data type to whatever is appropriate.

将数据类型更改为适当的类型。

For more info, see the documentation - specifically the methods available when dealing with the XML data type...

有关更多信息,请参见文档——特别是处理XML数据类型时可用的方法……