Problems with Turkish SQL Collation (Turkish "I")

Madeleine picture Madeleine · Apr 23, 2009 · Viewed 10.6k times · Source

I'm having problems with our MSSQL database set to any of the Turkish Collations. Becuase of the "Turkish I" problem, none of our queries containing an 'i' in them are working correctly. For example, if we have a table called "Unit" with a column "UnitID" defined in that case, the query "select unitid from unit" no longer works because the lower case "i" in "id" differs from the defined capital I in "UnitID". The error message would read "Invalid column name 'unitid'."

I know that this is occurring because in Turkish, the letter i and I are seen as different letters. However, I am not sure as to how to fix this problem? It is not an option to go through all 1900 SPs in the DB and correct the casing of the "i"s.

Any help would be appreciated, even suggestions of other collations that could be used instead of Turkish but would support their character set.

Answer

Madeleine picture Madeleine · Apr 27, 2009

Turns out that the best solution was to in fact refactor all SQL and the code.

In the last few days I've written a refactoring app to fix up all Stored procs, functions, views, tablenames to be consistent and use the correct casing eg:

select unitid from dbo.unit 

would be changed to

select UnitId from dbo.Unit

The app also then goes through the code and replaces any occurrences of the stored proc and its parameters and corrects them to match the case defined in the DB. All datatables in the app are set to invariant locale (thanks to FXCop for pointing out all the datatables..), this prevents the calls from within code having to be case sensitive.

If anyone would like the app or any advice on the process you can contact me on [email protected].