Case sensitive comparison in Sql server

to compare case sensitive fields in sql server u need to cast the fields to varbinary
then compare

for example

Scenario

select * from tbluser
username='test'

select * from tbluser
username='Test'

both of above queries will give same results


fix

select * from tbluser

cast (username as varbinary(lengthof username field)=
cast('test' as varbinary(length of usrname field)

Popular Posts