Skip to content

Instantly share code, notes, and snippets.

@shaneis
Created October 24, 2018 14:09
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save shaneis/2eb8ce6d2468814cf323114a20f47a7f to your computer and use it in GitHub Desktop.
Save shaneis/2eb8ce6d2468814cf323114a20f47a7f to your computer and use it in GitHub Desktop.
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