【问题标题】:BCP utility corrupts dataBCP 实用程序损坏数据
【发布时间】:2010-11-07 09:48:40
【问题描述】:

我正在将表的两列从一台服务器批量复制到另一台服务器。

源端的表大约有8列,但我只需要2列。

目标端的表有 2 列(我需要的两列,都是 int 类型)

两个数据库都是 SQL Server 2005。

这是我的两个 bcp 命令:

c:\> bcp "select c1, c2 from srcTable" queryout tableData.bcp -N -T -S srcServer
c:\> bcp destTable in tableData.bcp -N -T -S destServer

为什么这会破坏目标表中的数据?我应该得到很好的连续整数,而不是我得到这个:

c1          c2
586332      83014148
123128736   -105042384
-561616278  -309997736

我做错了什么?

【问题讨论】:

    标签: database sql-server-2005 bcp


    【解决方案1】:

    知道了。

    列定义必须完全匹配 - 包括它是 NULL 还是 NOT NULL。

    来源有:

    srcTable (
    c1 int not null (PK)
    c2 int null
    c3 datetime not null
    c4 datetime null
    ...
    )
    

    目标表有:

    destTable (
    c1 int not null (PK)
    c2 int not null 
    )
    

    destTable.c2 上的 NOT NULL 是错误。

    现在已经被压扁了。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2017-11-14
      • 2015-02-02
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多