sqlsql-serversql-server-2008hashbytes

Why The Query Against HashKey returns no records


I am working on a new sql table. The table has a column [varbinary(8000)], where we are storing hash of a certain text. Now, I am trying to retrieve the same record back by using a where clause against the hashkey, but that yields zero records.

I have added a similar query here: http://sqlfiddle.com/#!18/be996/11


Solution

  • Try without the single quotes, like this

    SELECT id, description
    FROM ForgeRock
    where id = 0x94EE059335E587E501CC4BF90613E0814F00A7B08BC7C648FD865A2AF6A22CC2
    

    and you will get the expected result.