December 18, 2012 at 1:20 am
Hello All,
I am sure some of the admin might have gone thorugh the same situation, I need a script that will give me common tables between 2 databases, we have 2 databases where 1 table has a entry in other and i am trying to merge these tables through export task which is failing coz the table names are already in there, so i was asked to come up with the names then we will decide if we need it or not. So please let me know how can we get the common tables across 2 databases.
Thanks in advance.....
Cheers...
December 18, 2012 at 2:17 am
An easy query:
SELECT name
FROM DB1.sys.[tables] t
WHERE [type] = 'U'
INTERSECT
SELECT name
FROM DB2.sys.[tables] t
WHERE [type] = 'U';
It doesn't take the schema into account.
Need an answer? No, you need a question
My blog at https://sqlkover.com.
MCSE Business Intelligence - Microsoft Data Platform MVP
December 18, 2012 at 2:40 am
Thanks Koen...It worked...exactly what i needed ....
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply