Click here to Skip to main content
15,790,267 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 is Live server and another one local databases .i have two databases... but how to compare??

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


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

If you don't mind paying or using a trial version, the Red Gate SQLCompare tool is excellent and well worth the money:[^]
Share this answer
Manas Bhardwaj 11-Jun-12 8:06am    
Good answer +5!
I often use:[^]

it's freeware and quite good for that ;-)
Share this answer
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:
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
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.

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
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.

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