Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 md hash in sql server

Author  Topic 

aakcse
Aged Yak Warrior

570 Posts

Posted - 2009-10-05 : 09:54:14
I would like to generate md hash value for a set of columns in sqlserver 2005

say if i have a columns names a b c
I want to concat them ( a,b,c) and generate hash value for all three
in a single column.

Regards,
cse.

X002548
Not Just a Number

15586 Posts

Posted - 2009-10-05 : 10:42:46
Do you have a hash algorithm?





Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page

robvolk
Most Valuable Yak

15732 Posts

Posted - 2009-10-05 : 13:18:10
If you're using SQL Server 2005 or higher, you can write a CLR function that uses the built-in .Net Cryptography library, which has MD5 and other hashing functions. Or, if you just need a checksum of some kind, SQL Server has CHECKSUM and BINARY_CHECKSUM functions built-in. Books Online has more details.
Go to Top of Page

aakcse
Aged Yak Warrior

570 Posts

Posted - 2009-10-05 : 13:24:06
Thanks all,

I used the below query..
select count(*), hashbytes('MD5',ltrim(rtrim(isnull(AutrName,'')))+
ltrim(rtrim(isnull(To,'')))+
ltrim(rtrim(isnull(CC,'')))+
ltrim(rtrim(isnull(BCC,'')))+
ltrim(rtrim(isnull(Subt,''))))
FROM Datquery
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2009-10-05 : 13:25:05
Depending on what you want to do there a couple of built in functions that may or may not meet you needs: HASHBYTES(), CHECKSUM() and BINARY_CHECKSUM().


EDIT: Dang, late to the party. That's what I get for starting a reply and then heading off to a meeting.. :)
Go to Top of Page
   

- Advertisement -