xp_cmdshell bcp 导出文件
开启xp_cmdshell
EXEC sp_configure ‘show advanced options’, 1;
RECONFIGURE;
EXEC sp_configure ‘xp_cmdshell’, 1;
RECONFIGURE;RECONFIGURE;@TOC
导出CSV文件
exec xp_cmdshell 'bcp “select *from kg_master.dbo.XCY_SAP_ORG " queryout “D:\data_files\11.csv” -c -t”||" -T -C
最后的参数 -T 表示这是信任的连接,也就是说不用输入密码了;-c 表示按字符类型输出;
-t “||” 表示用双||分隔