本文介绍了SQL Server HASHBYTES 转换不一致?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
当我执行这个硬编码时,我得到了正确的结果:
When I execute this hardcoded, I get the correct result:
Declare @result nvarchar(32) Set @result = convert(varchar(32), hashbytes('MD5', '1' + 'One' + 'Two' + 'Three'), 2) select @result结果: 4173AB4C6EE66BC1FF7B7E5D44A872CA(正确)
Result: 4173AB4C6EE66BC1FF7B7E5D44A872CA (correct)
但是当我调用/执行这个存储过程时,给它相同的参数,结果是不同的
But when I call/execute this stored procedure, giving it the same parameters, it's a different result
ALTER Procedure [db_owner].[CheckTheTransaction] @DataID nvarchar(50), @Data1 nvarchar(50), @Data2 nvarchar(50), @Data3 nvarchar(50) as Declare @result nvarchar(32) Set @result = convert(varchar(32), hashbytes('MD5', @DataID + @Data1 + @Data2 + @Data3), 2) Select @result我的执行:
DECLARE @result int EXEC @result = [db_owner].[CheckTheTransaction] @DataID = '1', @Data1 = 'One', @Data2 = 'Two', @Data3 = 'Three' SELECT 'Result' = @result GO结果: 5BD42777932EE959AD5A4C9FEE142F00(错误)
Result: 5BD42777932EE959AD5A4C9FEE142F00 (wrong)
我哪里做错了?
推荐答案我的团队成员提出了一个类似的问题并接受了解决它的答案.比较 C# 生成的校验和与 SQL Server 的校验和
My team member asked a similar question and accepted the answer that solved it. Comparing a C# generated Checksum with a SQL Server one
更多推荐
SQL Server HASHBYTES 转换不一致?
发布评论