Is there an equivalent to SHA1() in MS-SQL? Is there an equivalent to SHA1() in MS-SQL? mysql mysql

Is there an equivalent to SHA1() in MS-SQL?


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


If you want to get a SHA1 hash exactly as MySQL would generate it (i.e. as a varchar), you can combine HashBytes with sys.fn_varbintohexsubstring. E.g.

SELECT sys.fn_varbintohexsubstring(0, HashBytes('SHA1', 'password'), 1, 0)

See http://accessrichard.blogspot.co.nz/2010/12/sql-server-and-net-equivalent-to-php.html for more details.