Consider the following query:
SELECT HASHBYTES('MD5', (
SELECT * FROM dbo.BATCH WHERE batch_key = 22866 FOR XML AUTO))
It works fine.
But the following query:
SELECT HASHBYTES('MD5', (
SELECT * FROM dbo.BATCH WHERE batch_key = 22866 ))
returns the following error:
Msg 116, Level 16, State 1, Line 2
Only one expression can be specified in the select list when the subquery is not introduced with EXISTS.
Why is FOR XML XXX
required to perform a hash?