473,796 Members | 2,558 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

SQL2005 collation vs Oracle

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

May 11 '06 #1
27 16499
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
--

May 11 '06 #2
David,

I installed 2005 server with SQL_Latin1_Gene ral_CP1_CS_AS in hope to
acheive what you described, but look what happens:

3> create table t1 (c1 char(10))
4> go
2> NSERT INTO t1 VALUES('mike')
3> go
(1 rows affected)
1> INSERT INTO t1 VALUES('mike')
2> go
(1 rows affected)

1> SELECT * FROM T1 WHERE c1='Mike'
2> go
Msg 208, Level 16, State 1, Invalid object name 'T1'.
1>
2> SELECT * FROM t1 WHERE c1='Mike'
3> go
c1
----------
Mike

(1 rows affected)
1>

I wonder if collation you mentioned Latin1_General_ CS_AS is available at
server level?

Thanks,
Nasir
"David Portas" <RE************ *************** *@acm.org> wrote in message
news:11******** **************@ q12g2000cwa.goo glegroups.com.. .
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
--

May 11 '06 #3
Nasir wrote:
David,

I installed 2005 server with SQL_Latin1_Gene ral_CP1_CS_AS in hope to
acheive what you described, but look what happens:


That is correct. The "CS" part of the collation name means
Case-Sensitive. So you need to change it to Insensitive if you don't
require case-sensitive identifers. You can still specify a CS collation
for the column:

ALTER DATABASE junk COLLATE Latin1_General_ CI_AS ;

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

The collations beginning with SQL_ exist for backwards-compatibility
reasons. The Windows collations are preferred unless compatibility with
version 7.0 is required.

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

May 11 '06 #4
Nasir (nm*****@prosrm .com) writes:
I installed 2005 server with SQL_Latin1_Gene ral_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_Gene ral_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_C S_AS NOT NULL)

Obviously, this is quite messy, since you need to specify the collation
for every column.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.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
May 11 '06 #5
David Portas (RE************ *************** *@acm.org) writes:
The collations beginning with SQL_ exist for backwards-compatibility
reasons. The Windows collations are preferred unless compatibility with
version 7.0 is required.


One like to think so, but US English users are still offered an SQL
collation as a default when they install SQL 2005!
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.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
May 11 '06 #6
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!
"Erland Sommarskog" <es****@sommars kog.se> wrote in message
news:Xn******** ************@12 7.0.0.1...
Nasir (nm*****@prosrm .com) writes:
I installed 2005 server with SQL_Latin1_Gene ral_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_Gene ral_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_C S_AS NOT NULL)

Obviously, this is quite messy, since you need to specify the collation
for every column.
--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.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

May 11 '06 #7
Nasir wrote:
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!


If you use design tools and scripts to generate schemas (as surely most
of us do) then the fact that the schema is part of the column
definition shouldn't cause you any problem. You are really looking for
a syntax shortcut. You can always propose it at:
http://lab.msdn.microsoft.com/ProductFeedback/

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

May 12 '06 #8
Nasir (nm*****@prosrm .com) writes:
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!


Yes, if you try to use SQL Server as if it was Oracle, or vice versa, it
will be very painful.

I can agree that Oracle's way has a point - but in such case I would use
it the other way round: data case-insensitive, metadata case-sensitive.

My strong recommendation is that for development you should use case-
sensitive collation. Because if you develop under case-insensitive, and
the customer insists on case-sensitive, and you have used case
inconsistently, it will be very difficult to sort out. A collorary is that
it's a good idea to stick with all lowercase for names, so you don't end up
with both t1 and T1.

--
Erland Sommarskog, SQL Server MVP, es****@sommarsk og.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
May 12 '06 #9
I think Oracle got it right. It should not matter if you use MYTABLE,
MyTable, or mytable in your SQL statement FROM clause. The database
should recognize the table name. But data should be stored exactly as
entered so that mike, Mike, and MIKE should be different. There are
easy ways to handle forcing the data into a standard storage format via
column level constraints, table triggers, and single row functions like
UPPER, LOWER, and INITCAP. And there are ways to perform case
insensative compares where needed or desired.

Standarding data entry so that you do not end up with what amounts to
duplicates due to variation of entry has been an application issue
since computers were invented. Example: Johnson Inc. vs Johnson
Incorporated. Allowing the CAPLOCK key to add additional variables to
the mix is just asking for data integrity problems. Ever column of
every table in the application should have data entry rules. Then you
do not end up having to know or figure out if you are looking for MIKE,
mike, or Mike.

IMHO -- Mark D Powell --

May 12 '06 #10

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
2963
by: Matik | last post by:
Hello, I think I'd might have a small collation problem. Configuration: Two SQL Srv 2000 SP3 (running on clusters). Booth servers configured with SQL_Latin1_General_CP1_CI_AS collation. On each server, I have one database, which collation is
1
1812
by: John Jayaseelan | last post by:
Hi, The tempdb db is having different collation than the application db. I rebuilt the master db with the appropriate collation after backing up master, model, msdb, appln databases. On restore of the databases (master, model, msdb, appln) from the backup restores the backed up database collation.
2
1804
by: ad | last post by:
The user of my asp.net program use Sql2005 or Sql2005 express as database, both are possible. I have try both version of data base, I found: If I use Sql2005 express, the Data Source in connection string will be ..\SQLEXPRESS, like: Data Source=.\SQLEXPRESS;Initial Catalog=myDB;Integrated Security=True But I use Sql2005 , the Data Source in connection string can be use (local), like:
7
85153
by: Ryan | last post by:
I've stumbled across the above error and am a little stuck. I've just installed SQL2000 (sp3) on my PC and restored a database from our Live server. On a simple Update statement on a #temp table, it fails with the above message. I think I understand what it means and found some old posts suggesting using the following : select name, databasepropertyex(name, 'collation') from master..sysdatabases select serverproperty('collation')
5
3908
by: Mike | last post by:
I'm having trouble accessing SQL2005 Standard Edition as a second instance of SQL Server where the first instance is SQL 2000 Enterprise Edition. I installed SQL 2005 as a named instance "SQL2005". The server is running Windows 2000 SP4 ON A 32-Bit machine. When I look in Services I see the SQL Server (SQL2005), SQL Server Agent (SQL2005) services there. I went into SQL Server Configuration manager and disabled the named pipes protocol...
3
9706
by: aj | last post by:
A few collation questions on SQL Server 2005 SP2, which I'll call SQLS. The default collation for SQLS is apparently SQL_Latin1_General_CP1_CI_AS. I wish to use a variation of this, SQL_Latin1_General_CP1_CS_AI collation, but there is no such collation returned from fn_helpcollations(). Also, if I try to use this collation in a CREATE DATABASE stmt, SQLS yells about it. I see that there is a Latin1_General_CS_AI. What effects are...
3
2898
by: Michael Schöller | last post by:
Hello, First of all english is not my natural language so please fogive me some bad mistakes in gramatic and use of some vocables :). I have a great problem here. Well I will not use it anymore but I want to know why it is as it is ^^. I tried with .NET3.0 but I think it will be the same with 2.0 and 3.5. MSDTC is configured and working.
0
9680
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9528
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10230
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10174
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10012
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
9052
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7548
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5575
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4118
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.