首页 > 数据库 > SQL Server > 正文

sql server 2005 批量导入导出

2024-08-31 00:51:43
字体:
来源:转载
供稿:网友

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:/TDDOWNLOAD/test/' + @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


发表评论 共有条评论
用户名: 密码:
验证码: 匿名发表