views:

4535

answers:

4

Converting a couple stored procedures from MySQL to Microsoft SQL server. Everything is going well, except one procedure used the MySQL SHA1() function. I cannot seem to find an equivalent to this in MS-SQL.

Does anyone know a valid equivalent for SHA1() on MS-SQL?

+20  A: 

SQL Server 2005 and later has the HashBytes() function.

Joel Coehoorn
Looks perfect, answered while I took a leak. I love stackoverflow. Thanks!
Geoffrey Chetwood
Now if they'd just get support for a 256-bit algo instead of only 160
Joel Coehoorn
+1  A: 

These guys look like they have a solution that includes it.

tloach
forget your link?
Joel Coehoorn
@Joel: Thanks, double-double-quoted it. That's what I get for spending too much time with vbscript
tloach
Interesting, but I like Joel's built in function.
Geoffrey Chetwood
@Rich: I assumed from your question that you were looking for SHA1, not just any hash function
tloach
@tloach: If you follow the link, you will see there is SHA1 in the HashBytes() function.
Geoffrey Chetwood
+2  A: 

From google groups - A Possibility

Jason Lepack
A: 

I don't believe there's native support, but you may want to check this out...

http://blogs.msdn.com/sqlcat/archive/2005/09/16/469257.aspx

theraccoonbear