if exists(select name from sysobjects
where name='import_excell' and type='P')
drop proc import_excell
go
create proc import_excell @table nvarchar(255),@path nvarchar(255), @sheetName nvarchar(255)
as
begin
exec sp_configure 'show advanced options',1
reconfigure WITH OVERRIDE
exec sp_configure 'xp_cmdshell', 1
RECONFIGURE WITH OVERRIDE
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure WITH OVERRIDE
declare @sql nvarchar(1000)
select @sql='delete ' + @table
exec sp_executesql @sql
select @sql='insert into '+@table+' select * FROM OpenDataSource( ''Microsoft.Jet.OLEDB.4.0'',''Data Source="'
+@path+'";User ID=Admin;Password=;Extended properties=Excel 8.0'')...['
+@sheetName+'$]'
exec sp_executesql @sql
end
一个向sql server 2005导入excell的存储过程
最新推荐文章于 2024-02-23 14:56:26 发布