![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
Hi there, Is it posible to set the collation of SQL server 2005 like Oracle, which is that objects names and column names are case-insensitive, but data is sensitive;e.g: In Oracle: --create lower-case table and column name create table t1(c1 char(10)); --Mike with upper-case J insert into t1 values('Mike'); --follwoing I'm changing case in the table name, but it works, however 'Mike' has to be with uppewr case M select * from T1 where c1='Mike' Above test fails in SQL server. Is there a collation which can make data 'literals' sensitive, but data dictionary or the object names and column names case insensitive? TIA, Nasir |
#3
| |||
| |||
|
|
Nasir wrote: Hi there, Is it posible to set the collation of SQL server 2005 like Oracle, which is that objects names and column names are case-insensitive, but data is sensitive;e.g: In Oracle: --create lower-case table and column name create table t1(c1 char(10)); --Mike with upper-case J insert into t1 values('Mike'); --follwoing I'm changing case in the table name, but it works, however 'Mike' has to be with uppewr case M select * from T1 where c1='Mike' Above test fails in SQL server. Is there a collation which can make data 'literals' sensitive, but data dictionary or the object names and column names case insensitive? TIA, Nasir Yes. In fact the collation for data is always determined at column level. The database collation defines whether identifiers are case-sensitive and is also the default for the column collation. Take a look at the collations topics in Books Online. CREATE TABLE t1(c1 CHAR(10) COLLATE Latin1_General_CS_AS NOT NULL /* ... */); INSERT INTO t1 VALUES('Mike'); INSERT INTO t1 VALUES('mike'); SELECT * FROM T1 WHERE c1='Mike'; Result: c1 ---------- Mike (1 row(s) affected) -- David Portas, SQL Server MVP Whenever possible please post enough code to reproduce your problem. Including CREATE TABLE and INSERT statements usually helps. State what version of SQL Server you are using and specify the content of any error messages. SQL Server Books Online: http://msdn2.microsoft.com/library/m...S,SQL.90).aspx -- |
#4
| |||
| |||
|
|
David, I installed 2005 server with SQL_Latin1_General_CP1_CS_AS in hope to acheive what you described, but look what happens: |
#5
| |||
| |||
|
|
I installed 2005 server with SQL_Latin1_General_CP1_CS_AS in hope to acheive what you described, but look what happens: |
#6
| |||
| |||
|
|
The collations beginning with SQL_ exist for backwards-compatibility reasons. The Windows collations are preferred unless compatibility with version 7.0 is required. |
#7
| |||
| |||
|
|
Nasir (nmajeed (AT) prosrm (DOT) com) writes: I installed 2005 server with SQL_Latin1_General_CP1_CS_AS in hope to acheive what you described, but look what happens: David's post may require some clarification. In SQL Server you can set collation on three levels: 1) Server 2) Database default 3) Column level To simplify, let's assume that server and database default are the same. If you want table names to be case-insensitive (which is a bad idea in my opinion), the you install the server with a case-insensitive collation, such SQL_Latin1_General_CP1_CI_AS or Latin1_General_CI_AS. Then you create every table character column to be case-sensitive: CREATE TABLE t1 (c1 char(10) COLLATE Latin_General_CS_AS NOT NULL) Obviously, this is quite messy, since you need to specify the collation for every column. -- Erland Sommarskog, SQL Server MVP, esquel (AT) sommarskog (DOT) se Books Online for SQL Server 2005 at http://www.microsoft.com/technet/pro...ads/books.mspx Books Online for SQL Server 2000 at http://www.microsoft.com/sql/prodinf...ons/books.mspx |
#8
| |||
| |||
|
|
So going back to my original question - seems like it really does not support at the server level setting of SQL 2005, to achieve table and column names insensitive and chacter data to be sensitive. Is that correct? To get the character data sensitive I have to modify each column with collate, what a mess! I'm surprised that so many people are OK/fine with Oracle way of dictionary insensitve and data sensitive, but it's so hard to get thatin SQL. There got to be a btter way! |
#9
| |||
| |||
|
|
So going back to my original question - seems like it really does not support at the server level setting of SQL 2005, to achieve table and column names insensitive and chacter data to be sensitive. Is that correct? To get the character data sensitive I have to modify each column with collate, what a mess! I'm surprised that so many people are OK/fine with Oracle way of dictionary insensitve and data sensitive, but it's so hard to get thatin SQL. There got to be a btter way! |
#10
| |||
| |||
|
![]() |
| Thread Tools | |
| Display Modes | |
| |