SQL Server 比较两个应该相同的查询的结果 [英] SQL Server compare results of two queries that should be identical

查看:39
本文介绍了SQL Server 比较两个应该相同的查询的结果的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在稍微修改 sql server 2005 存储过程以提高性能,我想快速确保旧存储过程和新存储过程返回完全相同的结果(列相同,我想确保行相同).

I am modifying a sql server 2005 stored procedure slightly for performance, and I would like to quickly make sure the old stored proc and the new one return the exact same results (the columns are the same, I want to make sure the rows are the same).

在 sql server 2005 中是否有一种简单的方法可以做到这一点?

Is there a simple way to do this in sql server 2005?

推荐答案

您可以使用 except 构造在两个查询之间进行匹配.

you can use the except construct to match between the two queries.

select * from (select * from query1) as query1
except
select * from (select * from query2) as query2

然后反向查询以查找与作为驱动程序的 query2 的差异:

Then reverse the query to find differences with query2 as the driver:

select * from (select * from query2) as query2
except
select * from (select * from query1) as query1

这篇关于SQL Server 比较两个应该相同的查询的结果的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆