alter table statement conflicted with column foreig constraint'fk_u2_keshi_u1_hostipal'. the conflict occurred in database'b',table'u1_hospital'这句话的意思是说a数据库中有个外键约束依然存在constraint'fk_u2_keshi_u1_hostipal',所以导数据的时候报错!

解决方案 »

  1.   


    可我已经用alter table 命令使所有外键都失效了啊,该怎么解决呢?
      

  2.   

    你用的是数据库复制吗?(发布和订阅),还是在B库了建立了相同的表结构后insert数据?
      

  3.   


    失效的方法alter table TABLE_NAME disable(enable) constraint KEY_NAME;
     异步操作可能会引起失效的外键重新再次恢复!
      

  4.   

    alter table TABLE_NAME disable(enable) constraint all;
    这样可不可以把表里的所有外键关系全部失效??
      

  5.   


    我没这样用过,不过你可以先查数据库中是否还存在有效的主外建约束:
    方法:
    select   
      外键表=object_name(b.fkeyid),   
      外键表列=(select   name   from   syscolumns   where   colid=b.fkey   and   id=b.fkeyid),   
      外键名=a.name,   
      主键表=object_name(b.rkeyid),   
      键表列=(select   name   from   syscolumns   where   colid=b.rkey   and   id=b.rkeyid),   
      主键名=(select   name   from   sysobjects   where   xtype='PK'   and   parent_obj=c.id)   
    from   sysobjects   a   
    join   sysforeignkeys   b   on   a.id=b.constid   
    join   sysobjects   c   on   a.parent_obj=c.id   
    where   a.xtype='F'   and   c.xtype='U' 
      

  6.   

    更改逻辑文件名时错误提示'newname' is not a recognized CREATE/ALTER DATABASE option.是什么意思?
      

  7.   


    你是打算数据库备份么?可以通过企业管理器进行备份!
    alter table statement conflicted with column foreig constraint'fk_u2_keshi_u1_hostipal'. the conflict occurred in database'b',table'u1_hospital' 
    这句话说明你的外键约束并没有失效啊
    USE A
    ALTER TABLE u1_hospital
       WITH  NOCHECK
    INSERT INTO B.u1_hospital
    SELECT * FROM u1_hospital