可以用DDL触发器,记录新增字段时执行代码,然后到目标数据库执行.

解决方案 »

  1.   

    如果新数据库的表要取代旧数据库的话,那就简单了,直接用DTS做就行了(直接将旧数据库中的表直接删除再导入新表),然后设置其执行计划
      

  2.   


    select a.name,
    (select value from sys.extended_properties where name='MS_Description' and major_id=id and minor_id=colorder) as Alias,
    CASE WHEN COLUMNPROPERTY(a.id, a.name, 'IsIdentity') = 1 THEN 1 ELSE 0 END AS 标识,
    (select b.name from systypes AS b where a.xtype = b.xusertype) 类型, 
    a.length AS 长度 
    from syscolumns a 
    where id=object_id('U_item')可以用系统的函数syscolumns取得表的各个字段然后对比操作!
      

  3.   

    ap0405140的方法也是我们现在所采用的方法,具体的代码可以在sql server 2008的示例数据库中查到。
    另外,也可以用red gate的SQL Compare工具进行对比;或者建立专门的数据库版本控制(这个维护起来有点麻烦)。