Wednesday, 18 May 2011

Avoid Collation Issues

I had yet another query where the difference in the collation between my development database and tempdb that caused a TSQL error to be thrown.

The answer was to "collation proof" the query. It was really simple, you add the collation to be used into the query itself! below is the example.

WHERE #RawData.FullName = DiscrepancyReport.FullName COLLATE SQL_Latin1_General_CP1_CI_AS