SQL Server HASHBYTES 转换不一致?

编程入门 行业动态 更新时间:2024-10-28 20:26:17
本文介绍了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 转换不一致?

本文发布于:2023-10-19 14:19:34,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1507783.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:SQL   Server   HASHBYTES

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!