[英]creating bcp format file for sql server 2005
I am stuck in creating bcp format file. 我被困在创建bcp格式文件中。 My client is using MSSQL 2005 and I am remotely connecting through RDC. 我的客户端正在使用MSSQL 2005,并且通过RDC进行远程连接。 I am creating format file on the target client MSSQL Server using the following command, 我正在使用以下命令在目标客户端MSSQL Server上创建格式文件,
bcp myDatabase.TableName format nul -c -x -f someFile..xml -T bcp myDatabase.TableName格式nul -c -x -f someFile..xml -T
but the it prompt me with error 但是它提示我错误
An Error has occured while establishing a connection to the server. 建立与服务器的连接时发生错误。
My View pointing to a table having structure as under: 我的视图指向具有如下结构的表:
Colum Name DataType
SKU Varchar(20)
ASIN Varchar(20)
Price Float
Quantity Int
MarketplaceTitle Varchar(50)
Note: I have been through many similar questions but had no luck. 注意:我曾经遇到过许多类似的问题,但是没有运气。
Anyone can please provide me with a format file for the above View? 任何人都可以为我提供上述视图的格式文件吗?
Thanks in advance. 提前致谢。
It sounds like your issue is actually connecting to your database, not the format file. 听起来您的问题实际上是在连接数据库,而不是格式文件。
I've created a quick test: 我创建了一个快速测试:
-- DROP TABLE dbo.Test
CREATE TABLE dbo.Test(
SKU Varchar(20),
[ASIN] Varchar(20),
Price Float,
Quantity Int,
MarketplaceTitle Varchar(50)
);
and here's a slightly more verbose syntax: 这是一个稍微冗长的语法:
bcp YourDatabaseName.dbo.Test format nul -c -x -f c:\YourDir\format.xml -T -S YourServerName
so for me, this looks like this: 所以对我来说,这看起来像这样:
bcp sandbox.dbo.Test format nul -c -x -f c:\Test\format.xml -T -S "(local)"
Here's the file generated: 这是生成的文件:
<?xml version="1.0"?>
<BCPFORMAT xmlns="http://schemas.microsoft.com/sqlserver/2004/bulkload/format" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<RECORD>
<FIELD ID="1" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="20" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="2" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="20" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
<FIELD ID="3" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="30"/>
<FIELD ID="4" xsi:type="CharTerm" TERMINATOR="\t" MAX_LENGTH="12"/>
<FIELD ID="5" xsi:type="CharTerm" TERMINATOR="\r\n" MAX_LENGTH="50" COLLATION="SQL_Latin1_General_CP1_CI_AS"/>
</RECORD>
<ROW>
<COLUMN SOURCE="1" NAME="SKU" xsi:type="SQLVARYCHAR"/>
<COLUMN SOURCE="2" NAME="ASIN" xsi:type="SQLVARYCHAR"/>
<COLUMN SOURCE="3" NAME="Price" xsi:type="SQLFLT8"/>
<COLUMN SOURCE="4" NAME="Quantity" xsi:type="SQLINT"/>
<COLUMN SOURCE="5" NAME="MarketplaceTitle" xsi:type="SQLVARYCHAR"/>
</ROW>
</BCPFORMAT>
HTH. HTH。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.