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「加載提示」] –
已更新,以添加訂單 –