April 10, 2013 at 2:13 am
Hello All,
Can someone tell me how can we find common tables between 2 databases? Any scripts or querry plzz.
thanks in advance...
April 10, 2013 at 2:51 am
sqlpanther (4/10/2013)
Hello All,Can someone tell me how can we find common tables between 2 databases? Any scripts or querry plzz.
thanks in advance...
common table , by name , by attributes or by data ?
~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one :ermm:
April 10, 2013 at 3:12 am
Yes with common tables, attibutes..no need for data..
April 10, 2013 at 6:28 am
if it just for a quick look - you could query sys.objects / sys.columns / sys.tables for what you want, then run the same query over linked server and put it into a temp table and do your analysis from there
April 10, 2013 at 7:29 am
Are the databases on the same server?
April 10, 2013 at 8:37 am
April 10, 2013 at 9:02 am
here's a really easy example:
--common tables between the two
SELECT name from SandBox.sys.tables
INTERSECT
SELECT name from Dictionary.sys.tables
--tables only in SandBox
SELECT name from SandBox.sys.tables
EXCEPT
SELECT name from Dictionary.sys.tables
--tables only in Dictionary
SELECT name from Dictionary.sys.tables
EXCEPT
SELECT name from SandBox.sys.tables
Lowell
April 10, 2013 at 9:08 am
Yes all the objects are in the same server
April 10, 2013 at 9:12 am
sqlpanther (4/10/2013)
Yes all the objects are in the same server
Then you can do as Lowell suggests...or something similar with sys.columns if you need to drill down further.
April 10, 2013 at 10:04 am
Lowell (4/10/2013)
here's a really easy example:
--common tables between the two
SELECT name from SandBox.sys.tables
INTERSECT
SELECT name from Dictionary.sys.tables
--tables only in SandBox
SELECT name from SandBox.sys.tables
EXCEPT
SELECT name from Dictionary.sys.tables
--tables only in Dictionary
SELECT name from Dictionary.sys.tables
EXCEPT
SELECT name from SandBox.sys.tables
Apart from that , you need to check the database.sys.all_columns for attributes comparison....
~ demonfox
___________________________________________________________________
Wondering what I would do next , when I am done with this one :ermm:
April 10, 2013 at 11:38 am
Thanks SSchap...and all you ...it was quite quite simple...
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply