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.
| 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, LastNamefrom databaseBOD.dbo.users where UserID = 4Select FirstName, LastNamefrom databaseEOD.dbo.users where UserID = 4I 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 1My 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. |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
|
|
|
|
|