我需要将表格BCP到制表符分隔文件中,但我需要表格第一条记录中的列名称.问题1:我是否认为BCP没有这方面的转换?问题2:如果没有,为什么?
我试着做以下事情:
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**
Run Code Online (Sandbox Code Playgroud)
格式文件如下所示:
9.0
1
1 SQLCHAR 0 100 "\r\n" 1 Column_Names SQL_Latin1_General_CP1_CI_AS
Run Code Online (Sandbox Code Playgroud)
这给我一个列名的文件,然后第二个BCP命令给我一个数据文件,我只是将两个DOS复制到一起.问题3:我聪明还是什么?问题4:为什么不起作用?我收到错误:
SQLState = S1000, NativeError = 0
Error = [Microsoft][SQL Native Client]Host-file columns may be skipped only when
copying into the Server
Run Code Online (Sandbox Code Playgroud)