Groups | Blog | Home
all groups > sql server programming > october 2004 >

sql server programming : Case Sensitive Search or Case inSensitive?


Alejandro Mesa
10/29/2004 9:33:03 AM
[quoted text, click to view]

select Collation = convert(sysname,databasepropertyex(db_name(),'Collation'))


[quoted text, click to view]

select
*
from
(
select cast('Smith' as varchar(25))
union all
select cast('smith' as varchar(25))
) as t(colA)
where
colA collate SQL_Latin1_General_CP1_CS_AS like 'S%'

select
*
from
(
select cast('Smith' as varchar(25))
union all
select cast('smith' as varchar(25))
) as t(colA)
where
colA collate SQL_Latin1_General_CP1_CI_AS like 'S%'



AMB


[quoted text, click to view]
David Portas
10/29/2004 9:36:02 AM
Case-sensitivity is determined by a Collation, which is defined for each
character column in a database and as a default value for the database and
the server. Read the topics on Collations and Collation Coercian to
understand which collation will be applicable in any particular circumstance.

To determine the collation of a column you can interrogate the
information_schema.columns view.

To determine whether the current database's *default* collation is
case-sensitive you can do:

SELECT CASE WHEN 'A'='a' THEN 'CASE INSENSITIVE' ELSE 'CASE SENSITIVE' END

--
David Portas
SQL Server MVP
--
Mark Wilden
10/29/2004 10:32:56 AM
[quoted text, click to view]

Case-insensitivity does add some extra processing, so yes, it will be
slower.

Prabhat
10/29/2004 9:34:33 PM
Hi All?

I know that My SQL Server 2000 (Default Installtion) DB is Case insensitive.
But How Do I Find that? Is there any Environment Variable?

And I have One Doubt...

Does the Search oc Character Field Differ if that is RUN on a Case Sensitive
DB or on a Case IN Sensitive DB? If Yes what is the Difference? and which
One is Faster?

Thanks
Prabhat

Prabhat
10/29/2004 10:44:10 PM
Hi,

Good example, But will the Case Sensitive Search will be faster then the
Default case InSensitive?

I will also Try to find that.

Prabhat

[quoted text, click to view]

Prabhat
10/29/2004 10:44:38 PM
Hi,

Thanks for suggestion, But will the Case Sensitive Search will be faster
then the Default case InSensitive?

I will also Try to find that.

Prabhat

[quoted text, click to view]

Mark Wilden
11/1/2004 8:35:54 AM
[quoted text, click to view]

I don't know exactly what happens behind the scenes, but consider that with
a case-sensitive search, only 'mark' will equal 'mark'. With a
case-insensitive search, 'mark' equals 'Mark', 'mARK, 'marK', etc. Instead
of simply matching one character against another, a case-insensitive search
has to match perform the additional mapping of (for example) upper to lower
case.

Prabhat
11/1/2004 3:05:03 PM
Hi Mark,

What are those Extra Processing so that That will make the
Case-insensitivity SLOW? can U please elaborate that?

Thanks
Prabhat

[quoted text, click to view]

Prabhat
11/2/2004 12:21:26 PM
Hi Mark,

Yes! I Think You are right.

Thanks
Prabhat

[quoted text, click to view]

AddThis Social Bookmark Button