views:

150

answers:

1

My SQL Server Management Studio suddenly went case sensitive on me. The database and server are both set to case insensitive

SQL_Latin1_General_CP1_CI_AS

I run queries like

Select * From mytable

and I get "invalid object name"

but if i run

select * from MyTable

i get data!!

I created a new database and created a dummy table and successfully ran case insensitive queries over there.

Any ideas what I can look into here?

EDITED

Here is the output of the statments from the answer given by @Sam. It is very strange that the Server and the Database both have case insensitivity defined, but the individual columns are case sensitive. The Create Table statements do not contain collation information - only collation Question: Why is the query using the table name case sensitive when the database is CI

Server Level Collation
-----------------------------
SQL_Latin1_General_CP1_CI_AS

Database Level Collation
------------------------------
SQL_Latin1_General_CP1_CI_AI

Name          Owner  Type       Created_datetime
------------- ------ ---------- -----------------------
ProfitCenter  dbo    user table 2009-08-06 13:02:56.180



Column_name                  Type        Length  Collation
---------------------------- ----------- ------- -------------------------------
ProfitCenterID               int         4       NULL
HierarchyNodeID              int         4       NULL
ProfitCenterStatusID         int         4       NULL
BICProfitCenterNumber        varchar     10      SQL_Latin1_General_CP1_CS_AS
ProfitCenterName             varchar     255     SQL_Latin1_General_CP1_CS_AS
BICDistrictNumber            char        10      SQL_Latin1_General_CP1_CS_AS
BICClientNumber              varchar     10      SQL_Latin1_General_CP1_CS_AS
ManagerEmail                 varchar     255     SQL_Latin1_General_CP1_CS_AS
ManagerFirstName             varchar     255     SQL_Latin1_General_CP1_CS_AS
ManagerLastName              varchar     255     SQL_Latin1_General_CP1_CS_AS
PCOpenDate                   datetime    8       NULL
PCCloseDate                  datetime    8       NULL
LastDayOperation             datetime    8       NULL
ContractType                 char        10      SQL_Latin1_General_CP1_CS_AS
ContractTypeDesc             varchar     50      SQL_Latin1_General_CP1_CS_AS
CBSPCTypeCode                char        3       SQL_Latin1_General_CP1_CS_AS
CBSPCTypeDesc                varchar     50      SQL_Latin1_General_CP1_CS_AS
SBCSPCFlag                   char        1       SQL_Latin1_General_CP1_CS_AS
SBCSPCGroupCode              char        3       SQL_Latin1_General_CP1_CS_AS
SBCSPCRate                   decimal     9       NULL
SBCSPCComponent              varchar     10      SQL_Latin1_General_CP1_CS_AS
SBCSPCAccount                varchar     10      SQL_Latin1_General_CP1_CS_AS
PaymentTerms                 varchar     25      SQL_Latin1_General_CP1_CS_AS
RiskRate                     varchar     25      SQL_Latin1_General_CP1_CS_AS
RiskRateCapFlag              varchar     3       SQL_Latin1_General_CP1_CS_AS
RiskCapRate                  numeric     9       NULL
BICAddedDateTime             datetime    8       NULL
BICUpdatedDateTime           datetime    8       NULL


Identity        Seed  Increment  Not For Replication
--------------- ----- ---------- -------------------
ProfitCenterID  1     1          1


RowGuidCol
------------------------------
No rowguidcol column defined.


Data_located_on_filegroup
--------------------------
PRIMARY


index_name                                 index_description                        index_keys
------------------------------------------ ---------------------------------------- ----------------------
ProfitCenter_PK                            clustered, unique located on PRIMARY     ProfitCenterID
ProfitCenter_Unique_BICProfitCenterNumber  nonclustered, unique located on PRIMARY  BICProfitCenterNumber


No constraints are defined on object 'dbo.ProfitCenter', or you do not have permissions.

No foreign keys reference table 'dbo.ProfitCenter', or you do not have permissions on referencing tables.
No views with schema binding reference table 'dbo.ProfitCenter'.

Server default collation
----------------------------------------------------------------
Latin1-General, case-insensitive, accent-sensitive, 
kanatype-insensitive, width-insensitive for Unicode Data, 
SQL Server Sort Order 52 on Code Page 1252 for non-Unicode Data

[EDIT] After several attempts of trying different combinations, suddenly, the database is no longer CaseSensitive. Magic!?

+3  A: 

Very strange. Perhaps these commands could help you track the issue down:

SELECT SERVERPROPERTY('Collation') AS 'Server Level Collation'

To see your default database collation:

SELECT DATABASEPROPERTYEX('Pubs', 'Collation') AS 'Database Level Collation'

To see column level collations of Customers table:

EXEC sp_help 'dbo.Customers'

To see server level collation settings in SQL Server 2000 as well as the previous versions:

EXEC sp_helpsort

To a listing of all available collations in SQL Server 2000:

SELECT * FROM ::fn_helpcollations()

For further information about specific collations:

SELECT COLLATIONPROPERTY('German_PhoneBook_CI_AS', 'CodePage')

SELECT COLLATIONPROPERTY('French_CI_AS', 'LCID')

SELECT COLLATIONPROPERTY('Latin1_General_CI_AS', 'ComparisonStyle')

My first thought is that you had a SET option switched on - although I had never heard of one for CS.

Perhaps try running a query through SQLCMD and see what happens.

Sam
Good answer. A minor niggle though: to make it clear, there should be 2 db collation checks one for "MYDB" and one for "model" (which is where the default collation comes from for new databases).
gbn