Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Compare 2 tables in 2 databases in same instance

Author  Topic 

ArpitNarula
Starting Member

16 Posts

Posted - 2011-01-14 : 04:54:46

Problem:

Table A in Database A1
Table B in Database B1

Above 2 databases are in same instance of the SQL server.

I need to compare their structures.

In Oracle somthing like
describe A
union
describe B


Please advise.
Thanks in advance.

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-01-14 : 05:10:13
in the SSMS select the table name and press Alt+F1 you will get same as Oracle's "Desc TableName" but you will need to copy the result into Excel .. do same for another table and copy the result into Excel.... And compare there :D with Union ..!!!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-01-14 : 05:26:11
or

EXEC sp_columns 'A'
EXEC sp_columns 'B'


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-01-16 : 05:42:10
you can even write a query on catalog view INFORMATION_SCHEMA.COLUMNS to get it.

like
 
USE [A1]
GO
SELECT * FROM INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'A'
UNION ALL
SELECT * FROM B1.INFORMATION_SCHEMA.COLUMNS WHERE TABLE_NAME = 'B'


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

ArpitNarula
Starting Member

16 Posts

Posted - 2011-01-17 : 00:36:26
Thanks a lot for your reply's guys.
That has been really helpful.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-01-24 : 11:15:11
wc

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -