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

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 compare 2 results and save unmatched records
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Posting Yak Master

249 Posts

Posted - 12/25/2012 :  13:49:32  Show Profile  Reply with Quote
Hi there,

I have table1 which has some raw data processed and saved in table2. Now I need to compare the data from these 2 tables by running different stored procedures, to see if they match. If yes then pass, if not then save the error and the different results fom comparison. I run exec sp1 param1, param2 to get results from table2 and runn exec sp2 parameter1, parameter2 ... to get results from table2. The results columns could be different, see follwoing: but the bold ones are the ones to be compared:

result1: ...ID, Code, Model, Num, ... Date
result2: ...ID, Name, Model, SerialNum, Date

Model and Date must be compared and if they're not match then I need save the ID and different values for Model and Date, in a third table. How can I do this? Thanks in advance and Merry Christmas!

Very Important crosS Applying yaK Herder

52326 Posts

Posted - 12/25/2012 :  23:51:03  Show Profile  Reply with Quote
you'll need temporary tables for that. Create two temporary tables to store sp result and then use it to compare Model and Date fields. use INSERT...EXEC statement to populate table with SP results. The table structure should be same as SP resultset

Another approach is below which is not recommended as it makes use of distributed query

SQL Server MVP

Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.02 seconds. Powered By: Snitz Forums 2000