1
我似乎无法找到合适的格式,导出使用EXEC的xp_cmdshell在SQL Server Management BCP列名数据studio.I've尝试以下变化EXEC xp_cmdshell的bcp语法
EXEC xp_cmdshell bcp "select "a_id","b_id","c_id" union select a_id,b_id,c_id from tablename out
"\\network_path\a.txt" -c -Uusername -Ppassword -Sservername"
而且
EXEC xp_cmdshell bcp 'select 'a_id','b_id','c_id' union select a_id,b_id,c_id from tablename out
'\\network_path\a.txt' -c -Uusername -Ppassword -Sservername'
而且
EXEC xp_cmdshell bcp 'select "a_id","b_id","c_id" union select a_id,b_id,c_id from tablename out
"\\network_path\a.txt" -c -Uusername -Ppassword -Sservername'
而且
EXEC xp_cmdshell bcp "select 'a_id','b_id','c_id' union select a_id,b_id,c_id from tablename out
'\\network_path\a.txt' -c -Uusername -Ppassword -Sservername"
我已经成功地使用了下面的命令来导出表,但是我也需要列名。
bcp tablename out "\\network_path\a_test.txt" -c -Uusername -Ppassword -Sservername'
用法:bcp {dbtable |查询} {in | out |查询|格式} datafile [-m maxerrors] [-f formatfile] [-e errfile] [-F firstrow] [-L lastrow] [-b batchsize] [-n本机类型] [-c字符类型] [-w宽字符类型] [-N保留非文本本机] [-V文件格式版本] [-q带引号的标识符] [-C代码页说明符] [-t字段终止符] [-r行终止符] [-i inputfile] [ - o-outfile] [-a packetsize] [-S服务器名称] [-U用户名] [-P密码] [-T可信连接] [-v版本] [-R区域启用] [-k保留空值] [ - E保持身份值] [-h“加载提示”] –
已更新,以添加订单 –