-1

我有这个选择查询,它给出输出“0x38F0A2D294A4AEBD1648C952D910AC51C40FE7”

SELECT HASHBYTES ('SHA1',CAST(54 AS varchar)+CAST(1 AS varchar)
+CAST('2013-07-26 16:30:49.9786317' AS varchar)+CAST(1 AS varchar))

即使知道 SQL 服务器是做什么的,我也无法将列与值进行比较。我正在这样做:

SELECT 'Worked!'
WHERE  HASHBYTES ('SHA1',CAST(54 AS varchar)+CAST(1 AS varchar)+
CAST('2013-07-26 16:30:49.9786317' AS varchar)+CAST(1 AS varchar))=0x38F0A2D294A4AEBD1648C952D910AC51C40FE7

这根本行不通。奇怪的是,它适用于值不同的其他情况。

4

1 回答 1

0

试试这个:

declare @Hashthis nvarchar(2000)
SELECT @Hashthis=HASHBYTES ('SHA1',CAST(54 AS varchar)+CAST(1 AS varchar)
+CAST('2013-07-26 16:30:49.9786317' AS varchar)+CAST(1 AS varchar))

SELECT 'Worked' where HASHBYTES ('SHA1',CAST(54 AS varchar)+CAST(1 AS varchar)
+CAST('2013-07-26 16:30:49.9786317' AS varchar)+CAST(1 AS varchar))=@Hashthis
于 2013-07-26T20:34:28.907 回答