exec master..xp_cmdshell
''bcp "SELECT * FROM tablename" queryout "C:/test.txt" -T -c -C 65001''
最后的参数 -T 表示这是信任的连接,也就是说不用输入密码了;-c 表示按字符类型输出;-C 65001 表示输出为 UTF-8 格式,其中 65001 是 UTF-8 的代码页。
另根据msdn里提示:SQL Server2008已不支持代码页65001(UTF-8 编码)。
文章出处:http://www.diybl.com/course/7_databases/sql/sqlServer/200855/113311.html