开发者

Is there a setting in SQL Server that makes references, to columns names, case sensitive?

I was working in a third party software's SQL Server (2000) database and I noticed that If I run the following query:

SELECT Field_1, Field_2, Field_3 FROM TableName WHERE employee_ID = '00123'

It throws the error:

Invalid column name 'employee_ID'.

But if I change it to:

SELECT Field_1, Field_2, Field_3 开发者_运维知识库FROM TableName WHERE Employee_ID = '00123'

It runs fine. The column uses the capital 'E' version. I have always been able to specify column names without regard to case. Is there some sort of setting that I don't know about that will make SQL Server case sensitive?


SQL Server schemas can be made case sensitive using collations

You can change the collation using ALTER DATABASE statements, alternatively you can change it at a table level with ALTER TABLE.

More information can be found here:

http://www.databasejournal.com/features/mssql/article.php/3302341/SQL-Server-and-Collation.htm http://support.microsoft.com/kb/325335


One of the settings that can affect this is the collation of the database. Also, the collation settings of the master database can effect resolution of database names, system stored procs, etc.


if your database was created with its default collation specified as a case-sensitive collation, your object names and column name will be case sensitive.

I believe the default collation is SQL_Latin1_General_CP1_CI_AS. Selectiong SQL_Latin1_General_CP1_CS_AS will give you the case-sensitive equivalent.

Note that the default may vary depending on the version of SQL server and the culture/locale settings on the box on which SQL Server is installed.

Myself, I find case-sensitive object names to be a royal PITA. YMMV.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜