Advertisements

Database Collation and trying to detect changes

–Test 1 If database collation is case insenstive and you are trying to detect changes on a column where only the case has changed, this will not detect

SELECT A.*

FROM (SELECT ‘SQLSERVERCASECOLLATIONTEST’ AS COLA,’COLLATIONA’ AS COLB) A

LEFT JOIN (SELECT ‘sqlservercasecollationtest’ AS COLA,’COLLATIONA’ AS COLB) B ON A.COLA=B.COLA

WHERE B.COLA IS NULL

–Test 2 If database collation is case insenstive and you are trying to detect changes on a column, this will detect

SELECT A.*

FROM (SELECT ‘SQLSERVERCASECOLLATIONTEST’ AS COLA,’COLLATIONA’ AS COLB,BINARY_CHECKSUM(‘SQLSERVERCASECOLLATIONTEST’,’COLLATIONA’) AS COLC ) A

LEFT JOIN (SELECT ‘sqlservercasecollationtest’ AS COLA,’COLLATIONA’ AS COLB,BINARY_CHECKSUM(‘sqlservercasecollationtest’,’COLLATIONA’) AS COLC ) B ON A.COLC=B.COLC

WHERE B.COLC IS NULL

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: