回答:
派生テーブル
SELECT
EMail,
hashbytes('SHA1', EMail) AS HashedEmail
FROM
(
SELECT LOWER(SUBSTRING([NAME], 4, 100)) + '@somedomain.com' as EMail
FROM sometable
) foo
またはCTE:
;WITH cEMail AS
(
SELECT LOWER(SUBSTRING([NAME], 4, 100)) + '@somedomain.com' as EMail
FROM sometable
)
SELECT
EMail,
hashbytes('SHA1', EMail) AS HashedEmail
FROM
cEMail
まず、haststringの代わりにハッシュバイトを書きたかったと思います。hashstringはSQL関数ではありません。
これが、あなたが私が望む希望をあなたに与えてくれるコードです。
DECLARE @yourvariable nvarchar (50) = '@somedomain.com';
SELECT LOWER(SUBSTRING([NAME], 4, 100)) + @yourvariable as EMail
,HashBytes('SHA1', LOWER(SUBSTRING([NAME], 4, 100)) + @yourvariable) as HashedEmail
FROM sometable;