获取任何 SQL 查询的 SHA-512 [英] Get the SHA-512 of any SQL query
问题描述
比较两个文本文件的常见做法是使用 SHA-512 [或任何其他相关的 SHA 算法].如果两个 SHA 结果不相同,则文件不完全相同.
A common practice to compare two text file is to use the SHA-512 [or any other realted SHA algo]. If two SHA results are not the same then the files are not exactely the same.
我想对两个 SQL 查询做同样的事情.我只想知道查询是否使用 SHA-512 [或 sha-256 也可以] 给出 100% 相同的结果?
I would like to do the same with two SQL queries. I just want to know if the queries gives 100% identical result or not with a SHA-512 [or sha-256 would be OK as well]?
这可以执行吗?我正在使用 SQL Server...
Is that possible to perform that? I am using SQL Server...
推荐答案
只是为了帮助...
据了解,两个查询都以相同的顺序返回相同的列.
It's understood that both queries return the same columns in the same order.
你必须这样做:
SELECT COUNT(*) FROM (
([YOUR_QUERY_A]
EXCEPT
[YOUR_QUERY_B]) -- A_B
UNION ALL
([YOUR_QUERY_B]
EXCEPT
[YOUR_QUERY_A]) -- B_A
) EX
如果返回 0,则两个查询返回相同
If returns 0, both queries return the same
用于测试目的:
SELECT COUNT(*) FROM (
(select 1 a
EXCEPT
select 1)
UNION ALL
(select 1
EXCEPT
select 1)
) EX
改变一些内部查询,看看有什么变化
Change some inner query and look what changes
这篇关于获取任何 SQL 查询的 SHA-512的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!