Reputation: 108
I have a table with a populated column of type binary(24). I want to increase this field length to binary(32). This part's easy enough. The problem I'm running into is when I try to query the table based on that field's previous value. (We were using a hashbytes function).
So BEFORE the field length increase, I could just use:
SELECT * FROM Table WHERE Field = HASHBYTES('md5', 'value')
AFTER the field length increase, this query returns nothing. How would I change the query to return the appropriate value? What can I add on to the end of the binary in order for it to be recognized?
Thanks!
Edit: I've apparently done something ELSE wrong, as this works fine.
CREATE TABLE #test (test binary(24) null)
insert into #test (test) values (hashbytes('md5', 'test'))
select * from #test
ALTER TABLE #test ALTER COLUMN test binary(32) null
select * from #test where test = hashbytes('md5', 'test')
drop table #test
Upvotes: 1
Views: 531
Reputation: 379
Could you use CONVERT in the WHERE to turn it back into binary(24) ?
Upvotes: 1