2009-08-11 45 views
1

我的SQL Server Management Studio突然對我大小寫敏感。數據庫和服務器都設置爲不區分大小寫SSMS中的區分大小寫

SQL_Latin1_General_CP1_CI_AS

我運行查詢像

Select * From mytable 

,我得到「無效對象名稱」

,但如果我跑

select * from MyTable 

我得到的數據!

我創建了一個新的數據庫並創建了一個虛擬表,並在那裏成功運行了不區分大小寫的查詢。

任何想法,我可以看看這裏?

EDITED

這裏是statments的由@Sam給出的答案輸出。非常奇怪的是,服務器和數據庫都定義了大小寫敏感性,但各個列都區分大小寫。創建表語句不包含整理信息 - 只整理 問題:爲什麼使用表名大小寫敏感的查詢時,數據庫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 

[編輯] 的嘗試不同的組合,經過多次嘗試之後突然間,數據庫不再是CaseSensitive。魔法!?

+0

不是你喜歡看的魔法類型,是嗎?其他人是否有權訪問數據庫? – Sam 2009-08-12 17:59:07

+0

對!我絕對不喜歡軟件中無法解釋的奧祕。有問題的數據庫在我的機器上,我是除我的域管理員以外的工作站上唯一的管理員。 – 2009-08-12 20:17:37

回答

3

很奇怪。也許這些命令可以幫助你跟蹤問題下來:

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') 

我首先想到的是,你有一個SET option接通 - 雖然我從來沒有聽說過一個CS的。

也許嘗試通過SQLCMD運行查詢,看看會發生什麼。

+0

很好的答案。儘管如此:爲了說清楚,應該有一個針對「MYDB」和一個針對「模型」(這是默認排序來自新數據庫的地方)的2分鐘排序檢查。 – gbn 2009-08-12 03:57:58