Geeks With Blogs
Rohit Gupta Engaging talk on Microsoft Technologies ....My Resume
DECLARE @check1 bigint
DECLARE @check2 bigint

Select @check1 = CHECKSUM_AGG(CHECKSUM(*))
FROM
(
    SELECT *
    FROM dbo.Orders (nolock)
)
AS Source

Select @check2 = CHECKSUM_AGG(CHECKSUM(*))
FROM
(
    SELECT *
    FROM dbo.Orders (nolock)
    WHERE IsSuccessful = 1
)
As Comparison

IF @check1 = @check2
    PRINT 'Queries are Equal'
ELSE
    PRINT 'Queries are NOT Equal'
Note: If order of rows is different it will not effect the result It does not do execution plan comparisons, simply checks if the rows returned by the two queries are the same or not More info Posted on Thursday, November 13, 2008 1:40 PM | Back to top


Comments on this post: Compare 2 SQL queries for equality

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © Rohit Gupta | Powered by: GeeksWithBlogs.net