Table conparison

  • I have restore some old data to a new database that now only has data from sometime ago.

    I want to check and see if our production database has everything that was in the old database as it seems we are missing a day of data.

    I would like to run a Left Outer Join with the Where clause to exclude matches in both tables. How can I do this between two databases on the same server? Should I import the old table into the production database with a new name and run it that way?

  • I would not suggest importing data into production that is not production data. Better to export from production to a test area.

    For your query, just specify the database name:

    select * from MyDatabase.dbo.MyTable

    join OtherDatabase.dbo.MyTable on ...........

  • Does your table have a primary key set up?

    If so, just do the left outer join on the key match. Put the suspected "full data" version on the left side of the join, with the "missing data" version on the right side. Then WHERE FullDataVersion.PK IS NULL should get you what you need. Make sure the SELECT list contains items from the full version so you know which data is missing.

    Brandie Tarvin, MCITP Database AdministratorLiveJournal Blog: http://brandietarvin.livejournal.com/[/url]On LinkedIn!, Google+, and Twitter.Freelance Writer: ShadowrunLatchkeys: Nevermore, Latchkeys: The Bootleg War, and Latchkeys: Roscoes in the Night are now available on Nook and Kindle.

Viewing 3 posts - 1 through 2 (of 2 total)

You must be logged in to reply to this topic. Login to reply