views:

63

answers:

6

I have to do checks between a development and release database and do this manually, which is both slow and not 100% reliable (I only visually inspect the tables).

Is there a quick and easy way to compare table schemas automatically? Maybe even a feature that does this built right into SQL server?

Edit: I'm comparing structure only, thank you for pointing this out.

+4  A: 

Data or structure or both? Try RedGate sql compare or data compare. They both have free trials and are awesome.

http://www.red-gate.com/products/SQL_Compare/index.htm

http://www.red-gate.com/products/SQL_Data_Compare/index.htm

StarShip3000
Just the structure. Is there a free version of that $400 beast?
Soo
There isn't a free version of anything that is better than red_gate's tools. This is something you should spend the money on.
HLGEM
I just downloaded DB Diff and it gets the job done for the simple tasks I do. I will keep Red Gate in mind in the future though.
Soo
+2  A: 

I'm a fan of SQL DBDiff, which is an open source tool you can use to compare tables, views, functions, users, etc. of two instances of SQL Server databases and generate a change script between the source and destination databases.

Tim S. Van Haren
I like open source :)
Soo
+1  A: 

For a free solution, you can use SQL Server Managements Objects to output the DDL script for each table, view, index, SP, UDF, etc. Then you can compare, either in code, or using a diff tool like WinMerge.

RedFilter
+2  A: 

There are some commercial products that do this; Visual Studio 2010 Premium Edition can compare schemas.

Some others:
http://www.red-gate.com/products/SQL_Compare/index.htm
http://www.apexsql.com/sql_tools_diff.aspx

jelbourn
A: 

You can use the SQL Management studio tools to "Generate scripts" from both databases. Then use your favorite text comparison tool to see any differences.

In the old days, this worked great, but in SQL 2005 the generate script code changed and the objects were no longer created in the same order, so the text comparison is less useful. I have not tested this in more recent versions of SQL so it may have been fixed. You can also try http://exportsqlscript.codeplex.com/ which I have used with good success to output the DDL as scripts for source code control and comparing versions.

References:

Michael Levy
And of course, my favorite text comparison tool is Beyond Compare from http://www.scootersoftware.com/
Michael Levy
I tried that exact thing (generating the scripts, and I even used beyond compare). Unfortunately, as your post states, it was a fail due to the ordering...
Soo
http://exportsqlscript.codeplex.com/ does fix this problem. And, as I reported this as a bug to Microsoft and in the log someone said "it is fixed in the next release". I never saw the fix from Microsoft.
Michael Levy