user1837575 user1837575 - 5 months ago 19
SQL Question

How do I compare two tables in different databases

I have two databases, which are basically identical running on the same machine.

I would like to compare the records in a table on database A vs the same table in database B

I would like to know which records exist in the table on database A that do not exist in the same table on database B.

Database A = "RICSTOREV341"
Database B = "RICHOSTV341"

The table is "Price_Tab"

The columns I would like to pull are F01, F26, F27, F19, F38

Can this be accomplished?

Answer

Yes, this can be done.

You could use something like a three part identifier to identify the tables in different database. Kinda like this :

RICSTOREV341.dbo.Price_Tab

Then you can perform a join on the primary key and fetch the result.

Comments