sql 导出大数据量 到excel

 

首先开启 xp_cmdshell

EXEC

sp_configure 'show advanced options', 1

GO

-- To update the currently configured value for advanced options.

RECONFIGURE

GO

-- To enable the feature.

EXEC

sp_configure 'xp_cmdshell', 1

GO

-- To update the currently configured value for this feature.

RECONFIGURE

GO

 

在f盘新建一个222.xls文件,执行下面语句

 

use master
declare @cmd varchar(5000) 
set   @cmd= 'bcp   "select * from DBName.dbo.DrugList"   queryout   "F:\222.xls "   -c   -T ' 
exec   master..xp_cmdshell @cmd
posted @ 2011-08-12 11:19  Chris Cheung  阅读(702)  评论(0编辑  收藏  举报