May 30, 2006 at 9:52 am
DECLARE
@HashThis varchar(255);
SELECT @HashThis = 'Hello world!'
SELECT HashBytes('MD5', @HashThis)
The default output is varbinary:
0x86FB269D190D2C85F6E0468CECA42A20
But I need it as char(32):
86FB269D190D2C85F6E0468CECA42A20
Does anyone know how to do this? I can't use the varbinary data type in my application. I can only use char(32) datatype. Thanks.
June 2, 2006 at 8:00 am
This was removed by the editor as SPAM
March 26, 2007 at 3:10 am
Your original message is getting old; did you find that the answer is to use the master.dbo.fn_varbintohexstr function?
November 27, 2007 at 9:35 am
Did you find an answer to this question? I am facing the same issue. I do not want to convert it to varbinary. I would like to use varchar instead.
Thanks in advance.
November 28, 2007 at 5:26 am
Try casting to bigint and using the fnNumber2AnyBase function at the following link.
December 3, 2007 at 8:28 pm
Also check out http://support.microsoft.com/kb/104829 for the (slightly old but still valid) Microsoft function.
February 24, 2008 at 8:55 am
There is an undocumented function that will help
DECLARE @HashThis varchar(255);
SELECT @HashThis = 'Hello world!'
SELECT HashBytes('MD5', @HashThis)
SELECT SUBSTRING(master.dbo.fn_varbintohexstr(HashBytes('MD5', @HashThis)), 3, 32)
April 2, 2013 at 1:51 pm
You can convert hashbytes to varchar through XQuery as well.
Here is the solution. http://raresql.com/2013/04/02/sql-server-how-to-convert-hashbytes-to-varchar/
MI
http://raresql.com
Viewing 8 posts - 1 through 7 (of 7 total)
You must be logged in to reply to this topic. Login to reply