我的SQL Server Management Studio突然对我产生了区分大小写。数据库和服务器都设置为不区分大小写
SQL_Latin1_General_CP1_CI_AS
我运行
之类的查询Select * From mytable
我得到“无效的对象名称”
但如果我跑
select * from MyTable
我得到数据!!
我创建了一个新数据库,并创建了一个虚拟表,并在那里成功运行了不区分大小写的查询。
我可以在这里查看任何想法吗?
EDITED
以下是@Sam给出的答案中的声明输出。很奇怪,服务器和数据库都定义了不区分大小写,但各列都区分大小写。 Create Table语句不包含排序规则信息 - 仅包括排序规则 问题:当数据库为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 :(得分: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运行查询,看看会发生什么。