Fetching case sensitive data from database

By default, a SQL fetches data on case insensitive where clause , but sometimes we want certain queries to be case sensitive (for example, the user names or passwords in a login table)

If you want to fetch case sensitive data from database you need to use like this (check underlined part)

select * from TABLE where LoginID=@LoginId and UserPass=@Password COLLATE SQL_Latin1_General_CP1_CS_AS

If this is set at database level then there is no issue but if not then we need to modify query as above..

 

Thanks

Advertisements
Posted in sql.

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s