How to check case sensitive password in sql server08

In my application I am posting a password to the database, say my password is PassworD123. Now this gives me the correct value, but when I use password123 it also gives me the correct value. So how to chaeck for case sensitive data in SQL server. Any demo code will help. Thanks.

+1


a source to share


4 answers


You can use COLLATE clause in your T-SQL statement.

Ref.



SELECT * FROM dbo.TableName WHERE Password = @ password COLLATE SQL_Latin1_General_CP1_CS_AS 

      

+2


a source


Why not use encryption to store passwords in the database like md5, because they will return different hashed versions like

Md5 password123 = 482c811da5d5b4bc6d497ffa98491e38

Md5 of PassworD123 = bbac8ba35cdef1b1e6c40f82ff8002ea



and when you compare the 2 of them, they are clearly different.

I think you are using ASP, so I don't know if it has a built-in md5 () function, but php has it. Another thing you should know is that if you store passwords in a database, it is best to store them with some sort of encryption that cannot be reversed.

+5


a source


The immediate answer to your query is here: http://sqlserver2000.databases.aspfaq.com/how-can-i-make-my-sql-queries-case-sensitive.html

However, I think your approach to storing / comparing passwords is a little flawed. You don't have to store the password directly in the database. At least MD5 is it or something.

+2


a source


Well, the short answer is to use case sensitive collation - the longer answer is not to store plaintext passwords in your database

+2


a source







All Articles