现在有一个项目,一个主服务器,一个备用服务器,现在需要把主服务器的数据同步到备用服务器上,但是在同步过程主服务器数据表中的identity字段同步到备用服务器中,这个字面就没有这个属性了。所以,系统在备用服务器上是无法应用的。
在网上也查了一些资料,没有好的解决办法。
请问如何处理?

解决方案 »

  1.   

    所以尽量不要用identity这玩艺
      

  2.   

    没太懂,是SET IDENTITY_INSERT XXX ON码?
      

  3.   

    系统的后台数据库的表里面已经有identity这个属性了,如果把这个属性去掉那这个系统的程序还得改。
      

  4.   

    可以再加两个字段,一个是同步的服务器的ID,
    一个是IDENTITY,保存对应关系.
    现在服务器的的IDENTITY 不用动
      

  5.   

    Are you using SQL2K or SQL2K5 (or later)? If SQL2K5 (or later), you can implement a standby server or log shipping rather than replication to achieve fast switch-over capability. If SQL2K, then it's still possible to manually configure log shipping. Obviously you need to script the movement of transaction logs manually rather than relying on system doing it for you under SQL2K5.However, if you must use replication, identity columns are no big issues either. You need to ensure you have the following system in place(1) configure all tables that have identity columns with Not For Replication clause. This ensures that subscribers will receive the records with the same identity value as publisher.(2) Prior to switching over the backup server, run a batch of DBCC CheckIDENT(TableName, reseed, last_used_key) on the standby database. You need to retrieve the last_used_key using select max(key_name) from mytable.With this system in place, switching from production over to the standby server using replicated data will be a breeze and you will not need to modify the database application itself.
      

  6.   

    备用服务器上的表的不设置identity就可以了,如果程序需要自增列的话用在备用表上用触发器实现
      

  7.   

    其实这种需求不应该用identity,如果性能要求不高的话应该用uniqueidentifier,这样就可以实现主服务器和备用服务器的双向同步了
      

  8.   

    看不懂英文??已经给你了解决办法:使用 not for replication on identity columns
    使用 dbcc checkident to reset identity value不需要修改程序
      

  9.   

     据我所知,数据库有一个复制和发布功能,既然是备用服务器,那就用这个功能罗,
    把服务器A上的数据库AData,复制服务器B上的数据库BData上去罗。那还能怎么样?
      

  10.   

    11楼的方法试了,不可以。
    备用服务器订阅成功后,IDENTITY这个字段就是已经改变。如果再执行类似如下的代码会有错误。
    DEclARE  @autoid int         
    set  @autoid=(SELECT MAX(autoid) FROM mysqlpub)                      
    if @autoid is NULL 
       SET @autoid=0
    DBCC CHECKIDENT (mysqlpub, RESEED,@autoid) 
    服务器: 消息 7997,级别 16,状态 1,行 7
    'mysqlpub' 不包含标识列。
    DBCC 执行完毕。如果 DBCC 输出了错误信息,请与系统管理员联系。
      

  11.   

    看了那么多还是不太明白问题出在哪里。如果备用表没有identity这个字段但也得有个像对应的列吧,不然程序应该会有问题的。那么这样的话还是会需要一个字段的咯,为了方便你就建个int字段不就得了。
      

  12.   


    To use dbcc checkident, you must have already taken your subscriber database out of subscription mode (which is necessary before you can bring it online for production use anyway).
      

  13.   


    What does 标识列 mean? I presume it is identity in English? If my understanding of the error message is correct, it is saying that the table you are referring to (mysql) doesn't have an identity column at all! Check to ensure you haven't inadvertently disabled identity on that table.In addition to what I said about taking the database out of the subscription mode, you actually only need to call dbcc checkident(tablename, reseed) without having to specify the seed value. In SQL 2000, the system will automatically look for the maximum value used and use it as the current seed.