SQL 导入EXCEL文件方法集合

IF EXISTS (SELECT name FROM sysobjects
   WHERE name = 'gcht_jzgh_temp' AND type = 'U')
   DROP Table gcht_jzgh_temp
--倒入excel文件
set @temp =   '''MSDASQL.1'''
set @temp1 = '''driver=Microsoft Excel Driver (*.xls);DBQ=' + @dir_name + ' '''
set @temp2 = '''select * from [Sheet1$]'''
set @temp3 = 'SELECT * INTO gcht_jzgh_temp FROM OPENROWSET(' + @temp  + ' ,' + @temp1 +  ' , ' + @temp2 +  ' ) '
--print @temp3
execute ( @temp3 )

你可能感兴趣的:(Excel)