| Author: Rajesh Ranjan 25 Nov 2008 | Member Level: Gold | Rating:  Points: 2 |
Hi,
Can you tell me what type of difference you want to get.
Regds Rajesh Ranjan
|
| Author: Rajesh Ranjan 25 Nov 2008 | Member Level: Gold | Rating:  Points: 6 |
Hi Freind,
Try bellow query
-----------If both database is in same Server then try this query
select d1.name,d2.name from database1.dbo.syscolumns,database2.dbo.syscolumns where d1.name<>d2.name and d1.id=object_id('Table1') and d2.id=(select id from database2.dbo.sysobjects where name='Table1' -------If databases are on different Server sp_addlinkedserver [Server ip] select d1.name,d2.name from database1.dbo.syscolumns,[server ip].database2.dbo.syscolumns where d1.name<>d2.name and d1.id=object_id('Table1') and d2.id=(select id from [server ip].database2.dbo.sysobjects where name='Table1')
It will return you difference between the name of columns in both tables
WIth the same query you can find out Difference between datatype and length
Regds Rajesh Ranjan
|
| Author: kiran 27 Nov 2008 | Member Level: Silver | Rating:  Points: 5 |
To return all rows in table1 that do not match exactly the rows in table2, we can just use EXCEPT like this:
select * from table1 except select * from table2
To return all rows in table2 that do not match exactly in table1, we reverse the EXCEPT:
select * from table2 except select * from table1
And to return all rows in table1 that match exactly what is in table2, we can use INTERSECT:
select * from table1 intersect select * from table2
|