Click here to Skip to main content
15,883,901 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi Developers,

how to compare Two database table structures using sql 2008 R2.one is Live server and another one local databases .i have two databases... but how to compare??


Please help me urgent....Thanks for advance...

Regrads
Aravind
Posted

For a free comparison tool, you could look at this one:

http://opendbiff.codeplex.com/[^]

If you don't mind paying or using a trial version, the Red Gate SQLCompare tool is excellent and well worth the money:

http://www.red-gate.com/products/sql-development/sql-compare/[^]
 
Share this answer
 
Comments
Manas Bhardwaj 11-Jun-12 8:06am    
Good answer +5!
I often use: http://dbcomparer.com/[^]

it's freeware and quite good for that ;-)
 
Share this answer
 
Comments
Tim Corey 11-Jun-12 8:47am    
Good answer. I'll have to try that one out. +5
Run a query on each that returns the table structure:
SQL
SELECT column_name, data_type, is_nullable, character_maximum_length FROM information_schema.COLUMNS WHERE table_name='myTable'
If the two queries return the same data, the tables are effectively the same.
 
Share this answer
 
Comments
Tim Corey 11-Jun-12 8:46am    
This will work for a simple column compare but it won't get things like indexes, triggers, keys, or other items that are attached to the table.
Following query will selects only matching columns in two different tables.

SQL
select distinct column_name ,data_type,is_nullable, character_maximum_length
FROM information_schema.COLUMNS
WHERE table_name='TableName1' OR  table_name = 'TableName2'
GROUP BY column_name,data_type,is_nullable, character_maximum_length  HAVING COUNT(*)>1
 
Share this answer
 
Comments
CHill60 27-Feb-14 18:24pm    
Reason for downvote...question is over a year old, already answered and your solution does not solve the OPs problem
Himen Suthar 28-Feb-14 1:59am    
Ok, No problem. I was looking for to find identical column in two different database tables.
I just got hint from this Discussion. I just posted my questions solution here.
Thanks

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900