1.例如,一个文件夹中有这么些文件,06100303.xls   06200303.xls  07100303.xls  08100303.xls 意思是要把这些文件名0610读入到SQL中作为其表中的字段内容(叫行业代码),把0303作为时间读入到SQL中作为表中的时间字段内容(时间标识)。
2.在06100303.xls中有些工作表,这些表也就是SQL中的表是一样的,每个.xls中包含的表是一样的,怎么批量导入这些表到相应的行业代码和时间标识作为表的一条记录?

解决方案 »

  1.   

    1.有一批EXCEL表格,要把这些EXCEL表的文件名读入到SQL中作为其字段名称,例如:10130303.xls,10190303.xls
    create table #t(fname varchar(260),depth int,isf bit)
    insert into #t exec master..xp_dirtree 'E:\EXCLE数据路径',1,12.在EXCEL中有些表,要把这个表和上面的EXCEL文件名对应作为一条记录放在SQL中,SQL中也是这些EXCEL中的的表。declare tb cursor for select fn='E:\EXCLE数据路径'+fname from #t
    where isf=1 and fname like '%.xls'  --取.xls文件(EXCEL)
    declare @fn varchar(8000)
    open tb
    fetch next from tb into @fn
    while @@fetch_status=0
    begin
    --具体操作
    fetch next from tb into @fn
    end
    close tb
    deallocate tb
    drop table #t