bcp 的一般用法
用法: bcp {dbtable | query} {in | out | queryout | format} 資料檔案
[-m 最大錯誤數] [-f 格式檔案] [-e 錯誤檔案] [-F 首行] [-L 末行] [-b 批大小] [-n 本機類型] [-c 字元類型] [-w 寬字元類型] [-N 將非文本保持為本機類型] [-V 檔案格式版本] [-q 引號識別項] [-C 字碼頁說明符] [-t 欄位結束字元] [-r 行終止符] [-i 輸入檔案] [-o 輸出檔案] [-a 資料包大小] [-S 伺服器名稱] [-U 使用者名稱] [-P 密碼] [-T 可信串連] [-v 版本] [-R 允許使用地區設定] [-k 保留空值] [-E 保留標識值] [-h"載入提示"] [-x 產生xml 格式檔案]匯入csv格式檔案Exec master..xp_cmdshell 'bcp "SSIS.dbo.tb2" in "E:\export.csv" -c -t"," -r"\n" -T'匯出成csvExec master..xp_cmdshell 'bcp "SSIS.dbo.tb2" out "E:\test.csv" -c -t"," -r"\n" -T'將特定查詢匯出成預設格式預設以定位字元間隔,"\n"換行Exec master..xp_cmdshell 'bcp "select carbrand,longitude from ssis.dbo.tb2" queryout "E:\test2.txt" -c -T'其他情況參考:http://msdn.microsoft.com/zh-cn/library/ms162802.aspx啟用xp_cmdshellEXEC sp_configure 'show advanced options', 1 GO RECONFIGURE GO EXEC sp_configure 'xp_cmdshell', 1 GO RECONFIGURE GO