Comparing columns

SELECT db1.TABLE_NAME db1_table, db1.COLUMN_NAME db1_column, db2.TABLE_NAME db2_table, db2.COLUMN_NAME db2_column FROM database1.INFORMATION_SCHEMA.COLUMNS db1 full join database2.INFORMATION_SCHEMA.COLUMNS db2 on db1.TABLE_NAME = db2.TABLE_NAME AND db1.COLUMN_NAME = db2.COLUMN_NAME WHERE db1.COLUMN_NAME IS NULL OR db2.COLUMN_NAME IS NULL
This snappet compare two databases and query for the tables and columns that has in diference.

This is very useful when you have diferent versions of a databases.

It works on SQLSERVER

Be the first to comment

You can use [html][/html], [css][/css], [php][/php] and more to embed the code. Urls are automatically hyperlinked. Line breaks and paragraphs are automatically generated.