一个向sql server 2005导入excell的存储过程
2009-06-05 23:57
381 查看
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
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的存储过程,循环修改数据例子
- SQL Server 2005 - 实作CLR存储过程
- 在执行一个 CLR 例程或 SQL Server 2005 中使用程序集时的错误消息:"在主机存储区中的组件在 GAC 中有一个不同的签名比程序集。
- 在Visual Studio 2005中调试SQL Server 2005的存储过程
- sql server 2005查看数据库schema, user 的存储过程
- 配置 SQL Server 2005 远程调试存储过程 (转载)
- 在存储过程中编写正确的事务处理代码(SQL Server 2000 & 2005)
- SQL Server 2005 分页存储过程 row_number()
- sql server 2005/2008 加密存储过程解密
- SQL Server 2005 - 实作CLR存储过程
- 在Visual Studio 2005中调试SQL Server 2005的存储过程 (转)
- 获取所有SQL Server 2005存储过程的简便方法
- [导入]创建一个存储过程,根据系部编号查出男生、女生人数
- [翻译]使用C#创建SQL Server的存储过程(Visual Studio 2005 + SQL Server 2005)
- 破解SQL Server加密的存储过程的方法(含 sql 2000与sql 2005版)
- 基于SQL Server 2005新特性的分页存储过程
- 使用C#创建SQL Server的存储过程(Visual Studio 2005 + SQL Server 2005)
- SQL Server 2005存储过程学习笔记——数据操作
- SQL Server 2005 系统存储过程【清单】
- 在存储过程中编写正确的事务处理代码(SQL Server 2000 & 2005)