Wednesday, 14 January 2009

Database Collation - Facts I have known

Database collation is a property of the database which defined how data is stored , compared and retrieved.

this is pretty useful in cases where your application wants to perform case sensitive search or language specific search.

For one of my projects I had to install SQL Server , by default SQL Server chooses a case insensitive collation , However I chose a case sensitive collation.

I realised that a collation affects not only the data which is stored in the database but also any of the system tables , views etc.

Any queries which have been written so far will now work only if they have referenced the tables views columns in the correct case.

However there are ways you get around this problem:

  • Reset the collation of the database server by re-installing the server. This is crude but if you are facing lots of issues then this is one good option, but be sure to take backups of any databases which might have already created.
  • Rewrite the queries with the correct case. This can be a tedious task , but its the correct way of sql scripting as far as I think.
  • Chose the correct collation for any new database you create. This will ensure that any scripts which reference this database will need not worry about the case etc.
Since i was referencing the system tables in a very few places I had less issues.

But yes that's what I have know about collation.

No comments:

Post a Comment