使用TableDiff工具比对时的需要注意的问题

     SQLServer2005引入了TableDiff工具用来对比两个表之间的结构以及数据差异,在使用中可能遇到一些错误如下:

 

 

错误1.
原因:对比的源表没有主键的错误(在不使用-strict参数的情况下,目的表可以没有主键):
错误描述:The replication table difference tool requires the comparison tables/views to have either a primary key, identity, rowguid or unique key column.


错误2.
原因:对比的表的列数据类型不一致(如源表是varchar,目的表是int,但数据可以转换)
错误描述:如果不加-strict参数,下面的类型可以隐式转换,如果加了-strict参数,类型必须一致,否则错误一样

==============================================
源数据类型            目标数据类型 
---------------------------------------------- -
tinyint            smallint、int 或者 bigint
----------------------------------------------
smallint           int 或者 bigint
----------------------------------------------
int                   bigint
----------------------------------------------
timestamp              varbinary
----------------------------------------------
varchar(max)           text
----------------------------------------------
nvarchar(max)           ntext
----------------------------------------------
varbinary(max)          image
----------------------------------------------
text                   varchar(max)
----------------------------------------------
ntext                 nvarchar(max)
----------------------------------------------
image                varbinary(max)

==============================================

Table {dbname}.dbo.{tablename} on {sourceserver} and Table {dbname}.dbo.{tablename} on {destserver} have different schemas and cannot be compared.

 

 

错误3.
原因:对比的表包含sql_variant数据类型的列(不支持)
错误描述:Cannot compare the tables because they contain one or more columns of data type sql_variant. The tablediff utility does not support columns of this type.

 

 

以上只是其中一些问题,除了这些问题,还需要注意:

 

    tablediff 实用工具不能用于非 SQL Server 服务器。

 

另外在权限方面需要注意的是:

 

  

  若要比较表,您必须有要比较的表对象的 SELECT ALL 权限。

 

   若要使用 -et 选项,您必须是 db_owner 固定数据库角色的成员,或者在订阅数据库中至少有 CREATE TABLE 权限,并且对  目标服务器上的目标所有者架构拥有 ALTER 权限。

 

   若要使用 -dt 选项,您必须是 db_owner 固定数据库角色的成员,或者至少对目标服务器上的目标所有者架构拥有 ALTER 权限。

 

    若要使用 -o 选项,您必须对指定的文件目录位置拥有写入权限。

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值