How to return the SHA1 hash value of a string in SQL Server ?

SQL Server provides a function HashBytes function that returns the SHA1 , MD2 , MD4 and few other hash value of the specified input.

How to return the SHA1 hash value of a string in SQL Server ?

Just pass the ‘SHA1’ as the first parameter and the input as second parameter value to the HashBytes function to get the SHA1 hash value.

DECLARE @input nvarchar(max);
SELECT @input = CONVERT(nvarchar,'Welcome to Abundantcode.com');
SELECT HashBytes('SHA1', @input);
GO
How to return the SHA1 hash value of a string in SQL Server ?