Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 How to make select statement with "case sensitive"

Author  Topic 

markshen2006
Starting Member

15 Posts

Posted - 2008-04-30 : 13:06:52
Hi,

I am using SQL Server 2005 now.

I have to queries.that are

select 8 from testdb where name = 'TONY'

select 8 from testdb where name = 'tony'

the two queies get same results now. but 'TONY' and 'tony' are different if we need 'case sensitive'.

how to make the above queries get different result

My test data like following (testdb table)

name phone
TONY 12345
tony 67890

Thanks

Mark


tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2008-04-30 : 13:13:47
Use a case sensitive collation for that column.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Database maintenance routines:
http://weblogs.sqlteam.com/tarad/archive/2004/07/02/1705.aspx
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-30 : 13:15:12
Try using SQL_Latin1_General_CP1_CS_AS collation
Go to Top of Page

markshen2006
Starting Member

15 Posts

Posted - 2008-04-30 : 23:51:34
how to change the collation in sql server 2005?

Please give me the steps.

Thanks

Mark
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-04-30 : 23:57:50
select * from testdb where name COLLATE SQL_Latin1_General_CP1_CS_AS= 'TONY'

select * from testdb where name COLLATE SQL_Latin1_General_CP1_CS_AS= 'tony'
Go to Top of Page
   

- Advertisement -