July 1, 2008 at 11:56 pm
Hi All,
Is it possible to compare two xml through query?. For Example, i have a table column with xml data type. In that i need to compare (let's take 1st and 2nd row) through query.
Thanks for your assistance.
---
July 2, 2008 at 2:20 am
sqluser (7/1/2008)
Hi All,Is it possible to compare two xml through query?. For Example, i have a table column with xml data type. In that i need to compare (let's take 1st and 2nd row) through query.
Thanks for your assistance.
---
You cannot compare the xml directly, but if binary comparison is sufficient, you can cast to varbinary first. E.g.:
DECLARE @x1 XML
DECLARE @x2 XML
SET @x1 = ' '
SET @x2 = ' '
SELECT 'They are the same'
WHERE CAST(@x1 AS VARBINARY(MAX)) = CAST(@x2 AS VARBINARY(MAX))
If you need more complex comparison, you may want to write it in C# or similar, and create a CLR user defined function.
Regards,
Andras
Viewing 2 posts - 1 through 1 (of 1 total)
You must be logged in to reply to this topic. Login to reply