Freigeben über


Sharing your T-SQL Code? Test it on a case sensitive SQL instance

(Reposting from cache - as the MSDN blog migration seemed to have lost my latest post)

Do you share your T-SQL code with others? If you do, then first of all, thanks for sharing. But next question - did you test it on a case sensitive SQL instance? 

Check out the following two queries:

SELECT DepartmentID
FROM HumanResources.Department

SELECT DepartmentId
FROM HumanResources.Department

Subtle difference indeed - and it is a difference that that I wouldn't have identified myself unless I had first tested the script on a case sensitive SQL instance (in my case, I use SQL_Latin1_General_CP1_CS_AS).

When you're coding a small admin or monitoring script, It is usually no big deal in the grand scheme of things (I don't mind making a few changes to "gift scripts" from others). But if you are sharing a big long script - you may exceed the number of changes that someone will tolerate before going with some other solution. My customer uses plenty of case sensitive servers, and it didn't take long before I changed my case insensitive ways... The same goes for demos - when creating demonstration scripts, test them on a case sensitive SQL instance.