create proc proc_insert_access
   @fname varchar(1000)
as
  begin
    set @fname='d:\teach\teach.mdb'    
    exec('SELECT a.* into ##temp2  FROM OPENROWSET(''Microsoft.Jet.OLEDB.4.0'',
    '''+@fname+''';''admin'';'''', student)
AS a ')
    insert into student (sage,sdept,sname,sno,ssex)
    select * from ##temp2
    drop  table ##temp2
  end exec proc_insert_access 'd:\teach\teach.mdb'

解决方案 »

  1.   

    drop proc proc_insert_access
    go
    create proc proc_insert_access
       @fname varchar(1000)
    as
      begin
    --    set @fname='d:\teach\teach.mdb'    
        exec('SELECT a.* into ##temp2  FROM OPENROWSET(''Microsoft.Jet.OLEDB.4.0'',
        '''+@fname+''';''admin'';'''', student)
    AS a ')
        insert into student (sage,sdept,sname,sno,ssex)
        select * from ##temp2
        drop  table ##temp2
      end exec proc_insert_access 'd:\teach\teach.mdb'