The password field in my user table (SQL Server 2008) is encrypted using HASHBYTES on insertion. I have a stored procedure with parameters for the username and plain-text password which does a SELECT using that username and the password sent through HASHBYTES, then returns the user record if it finds a match. The SP is always returning an empty recordset, but if I copy and paste just the SELECT from the SP to a new query window, it returns the matched record. There’re no other statements in the SP. I’m missing something here; what is it?
The password field in my user table (SQL Server 2008) is encrypted using HASHBYTES
Share
If the SELECT on its own works, but inside the procedure it does not, the first thing I would look for is parameter types. Hash will vary wildly on similar input, but different types: