代码如下:
CREATE PROCEDURE usp_SendData @locationid char(1),@StartDate datetime,@endDate datetime,@sort char(10),@filepath char(150) AS
begin
set nocount on
set @filepath=rtrim(@filepath)
--数据信息
create table #location
(f_locationid char(1),f_startdate datetime,f_enddate datetime
) insert into #location (f_locationid,f_startdate,f_enddate) values (@locationid,@startdate,@enddate) exec('insert into OPENDATASOURCE(''Microsoft.Jet.OLEDB.4.0'',''Data Source=' + @filepath + ''')...t_location (t_location.f_startdate1,t_location.f_startdate2,t_location.f_enddate1, t_location.f_enddate2,t_location.f_locationid) select substring(cast(#location.f_startdate as  char(20)),1,10),substring(cast(#location.f_startdate as  char(20)),10,10),substring(cast(#location.f_enddate as  char(20)),1,10),substring(cast(#location.f_enddate as  char(20)),10,10),#location.f_locationid from #check')
set nocount off
end
GO
t_location 表结构f_locationid char(1)
f_startdate1 date
f_startdate2 date
f_enddate1 date
f_enddate2 date
传入参数 'a','2001-08-14 00:00:00.000','2001-08-14 00:00:00.000','','D:\xxx\xx.mdb'