January 6, 2014 at 8:13 am
I'm trying to compare the data in two tables that store XML. I've tried a few different things. I tried to convert the xml to int and the Binary_Checksum.
With New_CodeXML as(
Select
binary_checksum(new.PracticeOfficeXML) as PracticeOfficeXML,
binary_checksum(new.FacilityXML) as FacilityXML
from ODS1Stage.show.SOLRProvider_nandita new),
Old_codeXML as (
Select
binary_checksum(newbu.PracticeOfficeXML)as PracticeOfficeXML,
binary_checksum(newbu.FacilityXML) as FacilityXML
from DataBackup.show.solrprovider_12_30_2013 newbu)
Select 'New Code' as Code,x.* from (Select * from New_CodeXML except Select * from Old_CodeXML) x
Union All
Select 'Old Code' as Code,y.* from (Select * from Old_CodeXML except Select * from New_CodeXML) y
I get the following error.
Msg 8184, Level 16, State 1, Line 2
Error in binarychecksum. There are no comparable columns in the binarychecksum input.
This same query works on nonXML files.
Any suggestions on how or what I should convert the XML to?
January 6, 2014 at 8:30 am
CHECKSUM & BINARY_CHECKSUM cannot accept text, ntext, image, cursor, xml, and noncomparable common language runtime (CLR) user-defined types. Try converting the XML data-type to VARCHAR.
With New_CodeXML as (
Select
binary_checksum(convert(varchar(max),new.PracticeOfficeXML)) as PracticeOfficeXML,
binary_checksum(convert(varchar(max),new.FacilityXML)) as FacilityXML
from ODS1Stage.show.SOLRProvider_nandita new),
Old_codeXML as (
Select
binary_checksum(convert(varchar(max),newbu.PracticeOfficeXML))as PracticeOfficeXML,
binary_checksum(convert(varchar(max),newbu.FacilityXML)) as FacilityXML
from DataBackup.show.solrprovider_12_30_2013 newbu)
Select 'New Code' as Code,x.* from (Select * from New_CodeXML except Select * from Old_CodeXML) x
Union All
Select 'Old Code' as Code,y.* from (Select * from Old_CodeXML except Select * from New_CodeXML) y
January 6, 2014 at 8:35 am
That worked perfect.
I appreciate it!
January 6, 2014 at 9:11 am
Better yet, stop storing denormalized data in the form of XML in your database (never mind storing it twice!). 😉
--Jeff Moden
January 6, 2014 at 10:18 am
I'm sure my company would love me saying that on day 3....
January 6, 2014 at 10:28 am
caippers (1/6/2014)
I'm sure my company would love me saying that on day 3....
You mean that you didn't say it already at day 1?:-)
Adi
--------------------------------------------------------------
To know how to ask questions and increase the chances of getting asnwers:
http://www.sqlservercentral.com/articles/Best+Practices/61537/
For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Viewing 6 posts - 1 through 5 (of 5 total)
You must be logged in to reply to this topic. Login to reply