简体   繁体   English

BCP 错误:只有在复制到服务器时才能跳过列

[英]BCP Error: columns may be skipped only when copying into the Server

When I issue this command (It looks silly but it works):当我发出此命令时(看起来很傻但确实有效):

BCP "declare @colnames varchar(max); select @colnames=coalesce (@colnames+char(9), '') 
+ Column_Name from db.information_Schema.columns where table_name='table1' order by 
ordinal_position; select @colnames" 
     queryout Table1_Columns.tsv -S?? -U?? -P?? -f** -e**

I get this error:我收到此错误:

[Microsoft][SQL Native Client]Host-file columns may be skipped only when copying into the Server [Microsoft][SQL Native Client]Host-file 列只有在复制到服务器时才能跳过

The format file is:格式文件为:

9.0
1
1 SQLCHAR 0 100 "\r\n" 1 Column_Names SQL_Latin1_General_CP1_CI_AS

Can someone tell me why I am getting this error?有人能告诉我为什么我会收到这个错误吗?

There's an active bug report for this: http://connect.microsoft.com/SQLServer/feedback/details/584001/bcp-table-out-with-format-file-does-not-work-if-file-specifies-less-columns-than-source-table .有一个活跃的错误报告: http : //connect.microsoft.com/SQLServer/feedback/details/584001/bcp-table-out-with-format-file-does-not-work-if-file-specifying-列数少于源表

One simple workaround would be to write the variable to a temporary table (not a #temptable, but rather a table that is temporary), and bcp out from that.一种简单的解决方法是将变量写入临时表(不是#temptable,而是临时表),然后bcp从中输出。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM