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

你可能感兴趣的:(Excel)