1.在目标数据中中执行以下代码,生成表结构比对Sql
1 select 2 ' if exists( 3 select 1 from dbo.syscolumns a 4 inner join sys.tables t on t.object_id = a.id 5 inner join systypes c on c.xusertype = a.xusertype 6 inner join sys.schemas s on s.schema_id = t.schema_id 7 inner join sysobjects t2 on t.object_id=t2.id 8 where t2.xtype=''u'' and t2.name='''+t2.name+''' and a.name='''+a.name+''' 9 )begin print 1 end else begin select '''+t2.name+''' as TableName,'''+a.name+''' as FieldName,'''+c.name+''' as FieldType, ''Lack Field'' as Status end' 10 from dbo.syscolumns a 11 inner join sys.tables t on t.object_id = a.id 12 inner join systypes c on c.xusertype = a.xusertype 13 inner join sys.schemas s on s.schema_id = t.schema_id 14 inner join sysobjects t2 on t.object_id=t2.id 15 where t2.xtype='u'
生成界面如下:
2. Copy 查询结果,在目标数据库中执行。
查询结果界面如下:
努力不给自己一点懒惰的理由,否则你会一蹶不振