sybase - compare columns for a table in different 2 databases -


i got 1 table in 2 different databases, in database number of columns 284 columns in other databse number of columns 281 columns there 3 columns missing.
there query (not tool have found out somthing called compare it ) can find missing columns ?
example:

database 1
column1
column2
column3
column4
column5
column6

database 2
column1
column2
column3

column5
column6


in above example column 4 missing, there query in sybase can tell me missing column?

create 2 temporary tables 2 tables in 2 different databases, suppose #tablecolumns1 , #tablecolumns2

create table #tablecolumns1(columnname varchar(255)) create table #tablecolumns2(columnname varchar(255))  insert #tablecolumns1 select sc.column_name sys.syscolumn sc, sys.systable st  sc.table_id = st.table_id , st.table_name = '<databasename1.tablename1>';  insert #tablecolumns1 select sc.column_name sys.syscolumn sc, sys.systable st  sc.table_id = st.table_id , st.table_name = '<databasename2.tablename2>'; 

now create 1 more temporary table #missingtablecolumns contain actual results of missing columns

create table #missingtablecolumns(columnname varchar(255), tablename varchar(255))  insert #missingtablecolumns (columnname, tablename) select columnname, '<table1name>' #tablecolumns1, #tablecolumns2  #tablecolumns1.columnname *= #tablecolumns2.columnname  insert #missingtablecolumns (columnname, tablename) select columnname, '<table2name>' #tablecolumns1, #tablecolumns2  #tablecolumns1.columnname =* #tablecolumns2.columnname 

hope solve problem.


Comments

Popular posts from this blog

html5 - What is breaking my page when printing? -

c# - must be a non-abstract type with a public parameterless constructor in redis -

ajax - PHP/JSON Login script (Twitter style) not setting sessions -