How to get a list of all tables in two different databases?

SELECT * FROM database1. INFORMATION_SCHEMA. TABLES UNION ALL SELECT * FROM database2.

INFORMATION_SCHEMA. TABLES UPDATE In order to compare the two lists, you can use FULL OUTER JOIN, which will show you the tables that are present in both databases as well as those that are only present in one of them: SELECT * FROM database1. INFORMATION_SCHEMA.

TABLES db1 FULL JOIN database2. INFORMATION_SCHEMA. TABLES db2 ON db1.

TABLE_NAME = db2. TABLE_NAME ORDER BY COALESCE(db1. TABLE_NAME, db2.

TABLE_NAME) You can also add WHERE db1. TABLE_NAME IS NULL OR db2. TABLE_NAME IS NULL to see only the differences between the databases.

1 Cool, I could have sworn this didn't work! Even works with the SQL Server specific db1.sys.tables. – Andomar Jul 4 at 7:01 Thanks, that works.

– M4N Jul 4 at 8:31 Thanks a lot for the update! – M4N Jul 4 at 9:50.

As far as I know, you can only query tables for the active database. But you could store them in a temporary table, and join the result: use db1 insert #TableList select (...) from sys. Tables use db2 insert #TableList2 select (...) from sys.

Tables select * from #TableList tl1 join Tablelist2 tl2 on ...

Just for completeness, this is the query I finally used (based on Andriy M's answer): SELECT * FROM DB1. INFORMATION_SCHEMA. Tables db1 LEFT OUTER JOIN DB2.

INFORMATION_SCHEMA. Tables db2 ON db1. TABLE_NAME = db2.

TABLE_NAME ORDER BY db1. TABLE_NAME To find out which tables exist in db2, but not in db1, replace the LEFT OUTER JOIN with a RIGHT OUTER JOIN.

Yes, and to find out both, you can use FULL OUTER JOIN instead. – Andriy M Jul 4 at 9:39.

I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.

Related Questions