Compare results from different database

I have a stored procedure that I execute on different databases to present results. What's the easiest way to compare these results ?
more ▼

asked Jun 23, 2012 at 06:15 AM in Default

davehd gravatar image

30 1 1 1

(comments are locked)
10|1200 characters needed characters left

1 answer: sort oldest

Funnily enough, I had the same requirement recently. I blogged my approach here: http://thelonedba.wordpress.com/2012/06/21/warning-wordbreaker-filter-or-protocol-handler-used-by-catalog-foo-does-not-exist/

The gist of the process is:

  1. Create temporary table (or two) to match the output of your stored procedure
  2. execute the stored procedure into the temporary table. This was complicated for me by it being on a separate server...
  3. Repeat, running the SP from the second server/database.
  4. Do your comparison.

It's all relatively straightforward, just a bit long-winded. I'm sure I could have written the code better, for example!

This technique only works if there is one recordset output by your SP.

Things you'll need to know about:

Hope this helps.

[4]: http://msdn.microsoft.com/en-us/library/ms189837.aspx
more ▼

answered Jun 23, 2012 at 12:08 PM

ThomasRushton gravatar image

ThomasRushton ♦
34.2k 18 20 44

Yep, that worked beautifully and was quite simple. Thaks so much Thomas!
Jun 24, 2012 at 05:44 PM davehd
(comments are locked)
10|1200 characters needed characters left
Your answer
toggle preview:

Up to 2 attachments (including images) can be used with a maximum of 524.3 kB each and 1.0 MB total.

New code box

There's a new way to format code on the site - the red speech bubble logo will automatically format T-SQL for you. The original code box is still there for XML, etc. More details here.

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here



Answers and Comments

SQL Server Central

Need long-form SQL discussion? SQLserverCentral.com is the place.



asked: Jun 23, 2012 at 06:15 AM

Seen: 509 times

Last Updated: Jun 25, 2012 at 11:10 AM