SQL Server的bcp实用程序会破坏varbinary(max)数据

时间:2018-05-22 17:06:36

标签: sql-server bcp

表格结构:

CREATE TABLE [dbo].[Binaries]
(
    [Id] [bigint] IDENTITY(1,1) NOT NULL,
    [Data] [varbinary](max) NULL,
    [SHA256] [varbinary](32) NULL,
    [CreatedDate] [datetime2](7) NOT NULL,
    [DeletedDate] [datetime2](7) NULL,
    [IsDeleted] [bit] NOT NULL
)

命令:

bcp MyDb.dbo.Binaries format nul -f E:\format.fmt -T -n
bcp MyDb.dbo.Binaries OUT E:\Binaries.bcp -f E:\format.fmt -T
bcp MyDb.dbo.Binaries IN E:\Binaries.bcp -f E:\format.fmt -T

格式文件:

14.0
6
1       SQLBIGINT           0       8       ""   1     Id                         ""
2       SQLBINARY           8       0       ""   2     Data                       ""
3       SQLBINARY           2       32      ""   3     SHA256                     ""
4       SQLDATETIME2        0       8       ""   4     CreatedDate                ""
5       SQLDATETIME2        1       8       ""   5     DeletedDate                ""
6       SQLBIT              1       1       ""   6     IsDeleted                  ""

Data列包含文档,即pdf文件,导入文件损坏后(差异大约5-10%,文件大小较小)。

原始数据库已从.bak文件中恢复。

服务器版本:

Microsoft SQL Server 2016 (SP1-GDR) (KB4019089) - 13.0.4206.0 (X64) Enterprise Edition (64-bit) on Windows 10 Pro N 6.3 <X64> (Build 17134: ) (Hypervisor) 

0 个答案:

没有答案