sql compare tables for differences

Solutions on MaxInterview for sql compare tables for differences by the best coders in the world

showing results for - "sql compare tables for differences"
Evaline
28 May 2017
1(SELECT * FROM T1 MINUS SELECT * FROM T2)   -- Rows that are in T1 but not in T2
2UNION ALL
3(SELECT * FROM T2 MINUS SELECT * FROM T1);  -- Rows that are in T2 but not in T1
Lisa
31 Sep 2018
1-- Find the different tables and columns between DB_NBR_1 and DB_NBR_2
2-- (just replace DB_NBR_1 and DB_NBR_2)
3select isnull(db1.table_name, db2.table_name) as [table],
4       isnull(db1.column_name, db2.column_name) as [column],
5       db1.column_name as scripts_col_name
6      ,db1.column_type as scripts_col_type
7       ,db1.column_precision as scripts_col_precision
8
9      ,db2.column_name as liquid_col_name
10      ,db2.column_type as liquid_col_type
11      ,db2.column_precision as liquid_col_precision
12from
13(select schema_name(tab.schema_id) + '.' + tab.name as table_name, 
14       col.name as column_name
15      ,y.name as column_type
16      ,y.precision as column_precision
17   from [DB_NBR_1].sys.tables as tab
18        inner join [DB_NBR_1].sys.columns as col
19            on tab.object_id = col.object_id
20         JOIN sys.types y ON y.user_type_id = col.user_type_id
21         ) db1
22full outer join
23(select schema_name(tab.schema_id) + '.' + tab.name as table_name, 
24       col.name as column_name
25      ,y.name as column_type
26      ,y.precision as column_precision
27   from [DB_NBR_2].sys.tables as tab
28        inner join [DB_NBR_2].sys.columns as col
29            on tab.object_id = col.object_id
30         JOIN sys.types y ON y.user_type_id = col.user_type_id
31         ) db2
32on db1.table_name = db2.table_name
33and db1.column_name = db2.column_name
34where (db1.column_name is null or db2.column_name is null)
35order by 1, 2, 3
36
queries leading to this page
how to find differences between two sql tablessql server compare two tablescompare sql statementsql query compare two tablessql compare two tables for differencessql compare two tables to find differencescompare values of two tables in oraclehow to compare two table columns in sqlhow to compare two tables in sql in different databasescomparer deux tables sqlsql differencesql compare tablescompare two tables in sqlhow to compare two tables in different sql serverssql server find difference between two tableshow do i compare two tables in matched records in sql 3fcompare two tables in sql for differencescompare sql databases and find table differencessql compare 2 tables for differencessql server compare two tables for differencescompare table sqlsql get difference between two tablescompare 2 sql tablescompare two tables sql differencessql to compare 2 tableshow to compare two table data in oraclecompare two tables in sql for differences from different databasescompare records in two tables sqlt sql compare two tablescompare tables matching columns t sqlcompare tables matching columns sql how to compare two values from different tables in sqlcompare row differences sqlsql compare tablesql 2 table comparecompare column differences in two tables sqlsql table data compareoracle sql compare datacompare two same tables in sqlsql compare to tablessql compare values from 2 tablessql diff two tablescompare 2 tables sqlquery to compare two tables in sqlcompare 2 tables in sqlhow to compare 2 tables in sqlsql differences between two tablessql compare tab 22msql 22 compare tablescompare two tables all column in sql server for differenceshow to compare two table in sqlsql comparesql table differences comparequery to find difference between two tables in sqlsql 2 tables comparesql two table differencecompare two sql queries for differencest sql compare two tables for differenceshow to compare two tables in sql serversql compare tables for differencesdatabase compare two tablessql how to compare two tables their valueshowto compare same tables in sqlselect difference between two tables sqlsql compare two tables with different columnscompare tables in sqlsql query to compare two tableshow to diff 2 tables sqlsql get table differencesdifference syntax in sqlfind differences between two tables sqlcompare two tables in sql server for differencessql compare elemts on a tablecomparing two tables in sqlmsql compare tableshow to compare two tables data in sqldifference two tables sqlsql difference between two tableshow to find the difference between two tables in sqlsql compare two table columnsdifference between two tables sqlhow to find data difference between two tables in sql serverdifference in sqlcomparing 2 tables in sqlcompare from 2 tables sqlsql comparing two tables for differenceshow to compare two tables in sqlmsql compare tables for differencescompare tables in two my sql databases for differencescompare two sql tablescompare 2 tables in sql serversql difference tableminus in oracle sql 22sql server 22 compare two tablesoracle query minussql database differencesdifference between two columns in sqlsql compare two tablesoracle sql minuscompare 2 different sql tablesmsql compare two tables for differenceshow to do calculate between two tables in sqlsql query to compare values of two tableshow to compare data in two tables in sqlcompare two tables in sql oraclesql difference between two columnscomparing two tables in oraclecompare data of two tables in sql serverbasic sql comparesql how to compare two tables there valueshow to compare two tables in sql and find differences sql servercompare two tables in oracle for differencescompare two tables and return differences sqlhow to compare two tables in different sql databaseshow to compare two tables sql servercompare 2 tables in sql highlight differencesms sql compare two tableshow to compare two tables in sql and find differencesdifference between two tables compare two tables sqlhow to compare attributes in sql tables for differencesget difference between two tables sqlcompare 2 sql query for differencessql query compare 2 tablescompare sqlfind difference between two sql tablescompare data in two sql tablesoracle compare tablessql compare 2 queries for differencesminus sql oraclecompare two table sql querysql two tables data comparecompare two different tables in sqlsql comparing two tabefind difference between two tables sqlcompare tables sql serversql sentencia compare table structurecompare differences in two tables sqloracle compare datafind all differences in 2 tables sqlhow do you compare two tables in sqlcompare two tables data in sql t sql difference between 2 tablessql 2 tables differencesql server difference between two tablessql compare values in two tablessql compare columns in two tablescomparing 2 table in sqlcompare tables in two databases for differenceshow to find difference between two tables in sql accesscompare two tables in oraclet sql compare tablessql comparing tablesoracle sql comparecompare all columns in two tables sqlcompare two sql tables for differencescompare tables 27 sqlsql compare tables for differences