Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Doing a Diff

Author  Topic 

dukey07
Starting Member

16 Posts

Posted - 2005-10-03 : 12:01:01
I have a requirement to compare recordsets of the same query as it is run against two different sources. I am looking for an efficient way to do a diff.

For Example:


Select FirstName, LastName
from databaseBOD.dbo.users where UserID = 4


Select FirstName, LastName
from databaseEOD.dbo.users where UserID = 4

I want to compare these two records sets. If all atttributes are the same I want to set the diffFlag to 0 else I want to set the diffFlag to 1

My first thought was to perhaps union the two queries, and then do a select distinct and count how many rows I have or something of that nature. Any thoughts?

Thanks!







nr
SQLTeam MVY

12543 Posts

Posted - 2005-10-03 : 12:32:35
Problem is that if you get multiple identical rows from one query and also it is inflexible - i.e. you can't give tolerances in the rec for things like floating point innaccuracies.

I do it by adding the rows to a table (columns names col001, col002, ...), another table to describe what the columns are, another to describe which fields should be checked between the two query entries, the query identifier and record identifiers and how they should be matched - group aggregates, each field, within tolerance, ...

==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2005-10-04 : 01:59:28
Refer this also
http://weblogs.sqlteam.com/jeffs/archive/2004/11/10/2737.aspx

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -