HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMinor

How to disable case sensitivity in SQL Server 2005 for object name (Table name)?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
casesqldisablesensitivity2005nameforhowserverobject

Problem

I have created a new database in SQL Server 2005 and execute generated script from the old database.

In that I have a table called MstCity

When I try to execute the following query which has the table name in uppercase MSTCITY

SELECT City FROM MSTCITY WHERE City = 'Junagadh'


I get an error


Invalid object name 'MSTCITY'

When I execute this SELECT statement it works fine

SELECT City FROM MstCity WHERE City = 'Junagadh'


In the old database both SELECT statement work fine. And both database are in SQL Server 2005 only.

Solution

Check the collation on the database. Then consider (but not flippantly) if it should be a CI (Case Insensitive) rather than a CS one.

Also look at the system databases. You may need to do a system rebuild to get it working right if you have built a system to migrate the database to. If your tempdb collation is different from the old box to the new one, you might find yourself with collation errors before too long.

Context

StackExchange Database Administrators Q#23179, answer score: 7

Revisions (0)

No revisions yet.