declare @CMD_STR varchar(100)
declare @i int
declare @memo nvarchar(50)
set @memo='数据分离'
set @i=0
while @i<=153
begin
insert into t
select top 15000 *
from dbo.gceclub_member_email
select @CMD_STR= 'bcp jive.dbo.t' + ' out C:TDDOWNLOADtest' + @memo+cast(@i as nvarchar(20)) + '.xls'+ ' -c -S 127.0.0.1 -U sa -P bizcom';
EXEC master.dbo.xp_cmdshell @CMD_STR
delete
from dbo.gceclub_member_email where Col001 in (select Col001 from t)
delete from t
set @i=@i+1
end
USE master
EXEC sp_configure 'show advanced options', 1
RECONFIGURE WITH OVERRIDE
EXEC sp_configure 'xp_cmdshell', 1
RECONFIGURE WITH OVERRIDE
EXEC sp_configure; 'show advanced options', 0