Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
When N'' doesn't equal ''.
WITH Algorithms ([algorithm]) AS (
SELECT [algorithm]
FROM (VALUES ('MD2'), ('MD4'), ('MD5'), ('SHA'), ('SHA1'), ('SHA2_256'), ('SHA2_512')) AS t([algorithm])
)
SELECT [algorithm],
t.hashed_varchar,
u.hashed_nvarchar,
checked_varchar = CHECKSUM('a'),
checked_nvarchar = CHECKSUM(N'a')
FROM Algorithms
CROSS APPLY (SELECT HASHBYTES([algorithm], CAST('a' AS varchar(1)))) AS t(hashed_varchar)
CROSS APPLY (SELECT HASHBYTES([algorithm], CAST('a' AS nvarchar(1)))) AS u(hashed_nvarchar);
GO
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.