XML columns are not comparable, i.e. >, < and =/!= operators are not defined for xml data type. However, you can use xml in conjunction with the methods it supports, specifically exist() is recommended for use in join conditions and predicates for performance reasons (can better leverage an xml index if present).
E.g.
select B.Title from Books B, Authors A where B.xmlcol.exist(
'/author/@lastname[.=sql:column("A.lastname")]') = 1 and A.country = 'Russia'
Technically, xml data type can be converted to string types and then manipulated and compared as strings. This practice is discouraged though. E.g. the following xml fragments are equal from the data model perspective, while their serialized string representations are not (they differ in attribute order and insignificant whitespace):
<GrigoryPogulsky attr1="smart" attr2="generous"/> and
<GrigoryPogulsky attr2="generous" attr1="smart" />
If one needs to create referential integrity/unique/primary key constraints based on xml columns, they can define a computed column that calls one of the xml data type methods (see BOL for more details as one is required to go through an extra hoop of creating a UDF that wraps the method invocation in SS2K5).
Grigory
данное сообщение получено с www.gotdotnet.ru
ссылка на оригинальное сообщение