我的过程为什么不行呢?高手帮kankan
CREATE procedure sp_insert
@filepath varchar(100),
@starttime bigint,
@overtime bigint
as
set nocount on
declare @filename varchar(50)
while @starttime<@overtime+1
begin
select @filename='call'+cast(@starttime as varchar(10))+'.log'
if not exists (select * from dbo.sysobjects where id = object_id(@filename)) /*检测是否有源表存在*/
begin
set @starttime=@starttime+1
continue
end
exec(' BULK INSERT call_history
FROM '''+@filepath+@filename+'''
WITH
(
FIELDTERMINATOR = '','',
ROWTERMINATOR = ''CR/LF'',
MAXERRORS=3
)')
select @starttime=@starttime+1
print'yijingwanchen'
end
GO
我是想将文本文件导入库文件内容如下:
'13115929865','101099','','1','2003-07-10 15:56:31','2003-07-10 15:56:54','0046')
'13328317677','05952726896','101099','9','2003-07-10 15:52:47','2003-07-10 15:56:56','0072')
'13328317677','101099','','1','2003-07-10 15:52:23','2003-07-10 15:56:59','0076;3;05952726896#;')
'13159215937','008659110109488','101099','6','2003-07-10 15:56:34','2003-07-10 15:57:04','0040')
'13159215937','101099','','1','2003-07-10 15:56:23','2003-07-10 15:57:04','0024;s2')
'13055736218','101099','','1','2003-07-10 15:56:38','2003-07-10 15:57:14','0073;3;05796388470#')
'13328693517','101099','','1','2003-07-10 15:56:21','2003-07-10 15:57:54','0084;3;05938872174')
'13030805279','101099','','1','2003-07-10 15:56:06','2003-07-10 15:57:59','0061;3;13859709456')
'13030805279','13859709456','101099','9','2003-07-10 15:57:01','2003-07-10 15:57:59','0038')
'13178293156','101099','','1','2003-07-10 15:57:05','2003-07-10 15:58:08','0033;3;13805948463#')
'13306963067','13805813645','101099','2','2003-07-10 15:56:38','2003-07-10 15:58:08','0034')
'13306963067','101099','','1','2003-07-10 15:56:08','2003-07-10 15:58:09','0009;1;1;11')
'13003813956','101099','','1','2003-07-10 15:56:48','2003-07-10 15:58:15','0088;3;05917675088#')
'13003813956','05917675088','101099','9','2003-07-10 15:57:06','2003-07-10 15:58:15','0045')
'13328636829','101099','','1','2003-07-10 15:56:47','2003-07-10 15:58:21','0086;3;013959760656#;s1;;')
'13067368583','101099','','1','2003-07-10 15:58:21','2003-07-10 15:58:32','0031')
'13306004416','101099','','1','2003-07-10 15:56:46','2003-07-10 15:58:36','0043;3;05956557812#')
'13306004416','05956557812','101099','9','2003-07-10 15:57:21','2003-07-10 15:58:36','0047')
'13328678600','101099','','1','2003-07-10 15:58:43','2003-07-10 15:58:53','0018;3')