Tuesday, July 27, 2010

case sensitive search

if the database collation property is case incentive then it wont do a case sensitive search, to execute the queries with case sensitive searches use the collate hint

 

create table tbl_test(myval varchar(50))

insert into tbl_test select 'a'

select * from tbl_test

-- gives incorrect result

select * from tbl_test where myval = 'A'

-- use the below query

select * from tbl_test where myval = 'A' collate SQL_Latin1_General_CP1_CS_AS

No comments:

Post a Comment

Featured Post

SQL Server AWS Migration BCP

stored procedure to generate BCP scritps to migrate the SQL Server database. Developed this stored procedure on my labs to simulate t...

Contributors