I had a weird situation in a clients database today. SQL Server 2005, database collation is case-insensitive, so I can write SQL queries using any case, without any problem ... except one. One particular column, in one particular table, is called 'DeadZone'. If I query like this: 'select Deadzone from TableName' - I get a column not found error like this: 'select DeadZone from TableName' - it works. Now the kicker, like this: 'select deadZone from TableName' - it works!
So only the 'Z' in the column name is case-sensitive! I created a similar column name in the same table, with a 'Z' in it, and that column isn't case-sensitive.
Any ideas? I'm sure I can work around this, probably by dropping and re-adding the column, but it would be good to get to the bottom of this one. BTW, the database is on a PC in Hungary, so is it possible that some Hungarian-specific character issues are causing this? Remembering that another column name with a 'Z' in it did not have the same issue.
-Graeme
Database collation For example, the default server-level collation in SQL Server for the "English (United States)" machine locale is SQL_Latin1_General_CP1_CI_AS , which is a case-insensitive, accent-sensitive collation.
To set or change the database collation If you are creating a new database, right-click Databases and then click New Database. If you do not want the default collation, click the Options page, and select a collation from the Collation drop-down list.
A case-insensitive collation ignores the differences between uppercase and lowercase letters for string comparison and sorting, whereas a case-sensitive collation does not. For example, in case-insensitive collation, “A” and “a” are equal.
By default, the collate clause will take SQL_Latin1_General_CP1_CI_AS (case insensitive). To check whether a particular column is applied case sensitive or case insensitive, we can check under collation column, which is shown in below figure: Now, let's create a table.
What is the exact collation? Hungarian does have a special Dz letter, which might be collated differently from D - so your problem might actually be d, not z.
Deadzone is [D][e][a][dz][o][n][e]
DeadZone is [D][e][a][d][Z][o][n][e]
deadZone is [d][e][a][d][Z][o][n][e]
I'd vote you up +1000 for weirdest thing I've seen this month if I could.
See related issue with LY: http://www.sqlservercentral.com/Forums/Topic19439-9-1.aspx
And I don't think dropping and re-adding your column is going to help. You should probably only use real Hungarian column names if you are going to use a Hungarian database collation!
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With