BCP从快照复制导入以进行恢复

时间:2017-09-21 16:00:23

标签: sql-server sql-server-2016 bcp

首先,我使用以下链接作为我的基础:Older post on SQL Server Forum

目标服务器是SQL Server 2016,它是分发服务器和订购服务器。源是SQL Server 2014.复制工作正常。这是关于手动加载表格。

我正在尝试从特定日期的一个快照复制源表中加载数据。我的命令如下:

MASTER.DBO.xp_cmdshell
  'bcp "MyDatabase.dbo.Invoices"
        in "\\UNCPath\SQLBKUP\unc\ReplicationDir_JOBSGROUP\20170916041316\Invoices_5#1.bcp"
        -SServerName -T -E -n -b 10000'

以下BCP错误,其中10条错误消息似乎与我表格中的10个DATETIME2字段相关:

  

输出
  NULL
  开始复制...
  SQLState = S1000,NativeError = 0
  错误= [Microsoft] [SQL Server的ODBC驱动程序13]数据类型的字段大小无效   SQLState = S1000,NativeError = 0
  错误= [Microsoft] [SQL Server的ODBC驱动程序13]数据类型的字段大小无效   SQLState = S1000,NativeError = 0
  错误= [Microsoft] [SQL Server的ODBC驱动程序13]数据类型的字段大小无效   SQLState = S1000,NativeError = 0
  错误= [Microsoft] [SQL Server的ODBC驱动程序13]数据类型的字段大小无效   SQLState = S1000,NativeError = 0
  错误= [Microsoft] [SQL Server的ODBC驱动程序13]数据类型的字段大小无效   SQLState = S1000,NativeError = 0
  错误= [Microsoft] [SQL Server的ODBC驱动程序13]数据类型的字段大小无效   SQLState = S1000,NativeError = 0
  错误= [Microsoft] [SQL Server的ODBC驱动程序13]数据类型的字段大小无效   SQLState = S1000,NativeError = 0
  错误= [Microsoft] [SQL Server的ODBC驱动程序13]数据类型的字段大小无效   SQLState = S1000,NativeError = 0
  错误= [Microsoft] [SQL Server的ODBC驱动程序13]数据类型的字段大小无效   SQLState = S1000,NativeError = 0
  错误= [Microsoft] [SQL Server的ODBC驱动程序13]数据类型的字段大小无效   NULL
  BCP副本失败
  NULL

由于这是一个快照复制,我使用.SCH文件重新创建结构,就像复制加载时一样。没变。我尝试使用格式文件(.FMT),并更改命令以使用它。错误的方式相同。

BCP是否记录了我遗漏的错误?我尝试使用-e和错误文件位置,但它创建了一个0字节文件。

真的希望有人能带领我帮助我。根据需要询问更多细节。我已经检查了版本,@@ LANGUAGE,日期格式(最好我知道的)以及其他帖子提到的内容。每晚在此服务器上使用同一服务器上的相同数据/ bcp源成功完成复制。我觉得我正在尝试找到复制服务使用的1个交换机来实现这一点。

编辑:添加FMT和SCH文件信息

FMT档案

13.0
25
1       SQLBIGINT           0       8       ""   1     InvoiceId                                      ""
2       SQLBIGINT           1       8       ""   2     JobId                                          ""
3       SQLDATETIME2        0       8       ""   3     CreatedDateTime                                    ""
4       SQLNCHAR            2       500     ""   4     ExternalId                                         SQL_Latin1_General_CP1_CI_AS
5       SQLINT              0       4       ""   5     SourceTypeID                                   ""
6       SQLCHAR             2       50      ""   6     Status                                             SQL_Latin1_General_CP1_CI_AS
7       SQLCHAR             2       2000    ""   7     Summary                                            SQL_Latin1_General_CP1_CI_AS
8       SQLCHAR             2       50      ""   8     InvoiceNumber                                      SQL_Latin1_General_CP1_CI_AS
9       SQLDATETIME2        1       8       ""   9     InvoicedOn                                         ""
10      SQLMONEY            0       8       ""   10    Tax                                                ""
11      SQLMONEY            0       8       ""   11    SubTotal                                           ""
12      SQLMONEY            0       8       ""   12    Total                                              ""
13      SQLMONEY            0       8       ""   13    Balance                                            ""
14      SQLCHAR             2       50      ""   14    RoyaltyStatus                                      SQL_Latin1_General_CP1_CI_AS
15      SQLDATETIME2        1       8       ""   15    RoyaltySendOn                                      ""
16      SQLCHAR             2       1000    ""   16    RoyaltyMemo                                        SQL_Latin1_General_CP1_CI_AS
17      SQLDATETIME2        1       8       ""   17    ModifiedDateTime                               ""
18      SQLDATETIME2        1       8       ""   18    BatchModifiedDateTime                              ""
19      SQLDATETIME2        0       8       ""   19    UpdatedDateTime                                    ""
20      SQLDATETIME2        1       8       ""   20    RoyaltyDate                                        ""
21      SQLDATETIME2        1       8       ""   21    DepositedOn                                        ""
22      SQLBIT              1       1       ""   22    IsDeleted                                          ""
23      SQLBIGINT           1       8       ""   23    AdjustmentInvoiceID                            ""
24      SQLDATETIME2        1       8       ""   24    ExternalCreatedDateTime                            ""
25      SQLDATETIME2        1       8       ""   25    ExternalUpdatedDateTime                            ""

由Replication Snapshot Agent生成的SCH

drop Table [dbo].[Invoices]
go
SET ANSI_PADDING ON
go

SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
CREATE TABLE [dbo].[Invoices](
    [InvoiceId] [bigint] IDENTITY(1,1) NOT FOR REPLICATION NOT NULL,
    [JobId] [bigint] NULL,
    [CreatedDateTime] [datetime2](7) NOT NULL,
    [ExternalId] [nvarchar](250) COLLATE SQL_Latin1_General_CP1_CI_AS NOT     NULL,
    [SourceTypeID] [int] NOT NULL,
    [Status] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [Summary] [varchar](2000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [InvoiceNumber] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [InvoicedOn] [datetime2](7) NULL,
    [Tax] [money] NOT NULL,
    [SubTotal] [money] NOT NULL,
    [Total] [money] NOT NULL,
    [Balance] [money] NOT NULL,
    [RoyaltyStatus] [varchar](50) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [RoyaltySendOn] [datetime2](7) NULL,
    [RoyaltyMemo] [varchar](1000) COLLATE SQL_Latin1_General_CP1_CI_AS NULL,
    [ModifiedDateTime] [datetime2](7) NULL,
    [BatchModifiedDateTime] [datetime2](7) NULL,
    [UpdatedDateTime] [datetime2](7) NOT NULL,
    [RoyaltyDate] [datetime2](7) NULL,
    [DepositedOn] [datetime2](7) NULL,
    [IsDeleted] [bit] NOT NULL,
    [AdjustmentInvoiceID] [bigint] NULL,
    [ExternalCreatedDateTime] [datetime2](7) NULL,
    [ExternalUpdatedDateTime] [datetime2](7) NULL
)

GO

提前致谢。

KD

0 个答案:

没有答案