--导入数据
set @sql='openrowset(''MICROSOFT.JET.OLEDB.4.0'',''Excel 8.0;HDR=YES
;DATABASE='+@path+@fname+''',['+@sheetname+'$])'
exec('insert into '+@sql+'('+@fdlist+') select '+@fdlist+' from ['+@tbname+']')
set @sql='drop table ['+@tbname+']'
exec(@sql)
return
lberr:
exec sp_oageterrorinfo 0,@src out,@desc out
lbexit:
select cast(@err as varbinary(4)) as 错误号
,@src as 错误源,@desc as 错误描述
select @sql,@constr,@fdlist
go
----------------------------------------------------------
怎么样把excel文件导入到一个叫student的新表(里面没数据)中
---------------------------------------------------------
深入数据库编程...(dbdebuger)
如果你的student表结构与以下内容匹配.
95001李勇 男20CS
95002刘晨 女19IS
95003王敏 女18MA
95004张立 男17IS
那么用下面这个就可以
insert into student
SELECT *
FROM OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source="c:\zt.XLS";Extended Properties="Excel 8.0";Persist Security Info=False')...[a1$]