SQL Collation Made Easy
In what seems to be a common theme in my posts, here's a snippet of information that everyone probably already knows but I just learned about.
Have you ever had two tables you're trying to join in a query using text-based columns (eg varchar), but they're different collations so you get a "Cannot resolve the collation conflict" error when you run the query? Whenever I got that error I used to copy the database's collation name to the clipboard and paste it into the query. Inevitably it'd be something very ugly like, "SQL_Latin1_General_CP1_CI_AS" and make the query damn-near unreadable.
Well, I just learned that the "collate" keyword accepts a special value: "database_default". You can chuck "collate database_default" after one of your varchar column references and everything's dandy! Better still, that query becomes portable - if someone else used a script to create a copy of your database on their server with a different collation, the query will still run.
Wish I'd known about this one a few years ago when we had two databases talking to each other with different collations - it would have simplified those SQL statements a lot.