/*
设置sql权限导出Execl
EXEC sp_configure N'show advanced options', N'1'
RECONFIGURE WITH OVERRIDE
EXEC sp_configure N'xp_cmdshell', N'1'
RECONFIGURE WITH OVERRIDE
EXEC sp_configure N'show advanced options', N'0'
RECONFIGURE WITH OVERRIDE
*/
EXEC master..xp_cmdshell 'bcp AiFuMu_DB.dbo.AFM_ProductOutput out "c:\test.xls" -c -S"127.0.0.1" -U"sa" -P"123456"'
另类Sql语句直接导出表数据到Execl
本文转载:CSDN博客