将.bcp文件导入sql server

时间:2021-03-22 02:48:16

I have downloaded some ZIP files from a government website for study that are of type SQL Server Replication Snapshot Bulk-copy Data File. I am assuming they are .bcp files. I have also downloaded corresponding .sql files to be created in sql server. There is an additional separate zip file that contains a large .bcp file with no create table .sql file so I am not sure what it is for.

我从*网站下载了一些用于研究的ZIP文件,这些文件属于SQL Server Replication Snapshot Bulk-copy Data File。我假设他们是.bcp文件。我还下载了要在sql server中创建的相应的.sql文件。还有一个额外的单独的zip文件,其中包含一个没有create table .sql文件的大型.bcp文件,所以我不确定它是什么。

They are saved in c:\sadybcp\extract1...extract2.... I have created a database called test with tables extract1, extract2, extract3 etc all tables being different. I want to import them to my sql server. I searched unsuccessfully to get the syntax online , most of then are for .txt files. So I have tried various combinations but have failed.

它们保存在c:\ sadybcp \ extract1 ... extract2 ....我创建了一个名为test的数据库,其中包含表extract1,extract2,extract3等所有表都不同。我想将它们导入我的sql server。我没有成功搜索到在线获取语法,大多数是.txt文件。所以我尝试了各种组合,但都失败了。

For example I have tried Bcp Test.dbo.extract in C:\sadybcp\ extract.bcp

例如,我在C:\ sadybcp \ extract.bcp中尝试了Bcp Test.dbo.extract

but I get error unknown argumentextract1 on command line

但我在命令行上得到错误未知的argumentextract1

When I run bcp "Test.dbo.extract1" in C:\sadybcp\extract.bcp -S SADYPC -T -E -n -b 10000
I get error Unable to open BCP host data-file.

当我在C:\ sadybcp \ extract.bcp -S SADYPC -T -E -n -b 10000中运行bcp“Test.dbo.extract1”时出现错误无法打开BCP主机数据文件。

Please can anyone help me with the correct command ? I need to copy 15 files.

请任何人帮助我正确的命令?我需要复制15个文件。

1 个解决方案

#1


0  

It looks like there is problem with path/filename in the first example you provided. You probably used copy/paste to fill path to bcp file (space in the middle, maybe some white signs).

在您提供的第一个示例中,看起来路径/文件名存在问题。您可能使用复制/粘贴来填充bcp文件的路径(中间的空间,可能是一些白色标志)。

The second error could occur when path/filename is incorrect, file doesn't exist or file is in use.

当路径/文件名不正确,文件不存在或文件正在使用时,可能会发生第二个错误。

Is is worth noting, that paths are relative to where bcp utility is executing. Also be sure, that all security requirements are met (access to file).

值得注意的是,路径与bcp实用程序执行的位置相关。还要确保满足所有安全要求(访问文件)。

#1


0  

It looks like there is problem with path/filename in the first example you provided. You probably used copy/paste to fill path to bcp file (space in the middle, maybe some white signs).

在您提供的第一个示例中,看起来路径/文件名存在问题。您可能使用复制/粘贴来填充bcp文件的路径(中间的空间,可能是一些白色标志)。

The second error could occur when path/filename is incorrect, file doesn't exist or file is in use.

当路径/文件名不正确,文件不存在或文件正在使用时,可能会发生第二个错误。

Is is worth noting, that paths are relative to where bcp utility is executing. Also be sure, that all security requirements are met (access to file).

值得注意的是,路径与bcp实用程序执行的位置相关。还要确保满足所有安全要求(访问文件)。