SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

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

allan8964
Posting Yak Master

247 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!

visakh16
Very Important crosS Applying yaK Herder

India
52309 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

http://beyondrelational.com/modules/2/blogs/70/posts/10812/select-columns-from-exec-procedurename-is-this-possible.aspx

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New 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.06 seconds. Powered By: Snitz Forums 2000