Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2005 Forums
 Transact-SQL (2005)
 comapre exact contents of two text fields

Author  Topic 

mattt
Posting Yak Master

194 Posts

Posted - 2007-11-29 : 04:35:08
Hi,

I have two records in a table which appear to be identical. However, if I split them out into temp tables and try and compare the contents of one of the text fields in the record by using ...

select count(*) from #testt1 a, #testt2 b where a.markup like b.markup 


Then no rows are returned. Same is true if I convert the text to char and use the "=" operator.

The text in the field is quite long, and to the naked eye the contents of the two look identical. They certainly should be since both have come from the same source. I'm presuming therefore that this is some sort of hidden whitespace/ASCII matching issue.

Is there any way I can make a detailed comparison of these two fields within T-SQL itself and discover where the discrepancy is?

Cheers,
Matt

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2007-11-29 : 04:46:07
Try printing out lengths of both field values using LEN() function.
Go to Top of Page

mattt
Posting Yak Master

194 Posts

Posted - 2007-11-29 : 04:57:35
Thanks for this.

The lengths are indeed different. It helped me track down the problem - for some reason the text editor used to input the content of the two fields had insert one with a £ sign and the other with the HTML escape code for the £ sign. So when I printed both out on a web page they looked the same.

Very odd. Thanks for your help.
Go to Top of Page

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-11-29 : 05:02:42
Seems like you have some non-printing characters embedded in one of the value.

Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page
   

- Advertisement -