Excel导入SQL SERVER中
--Excel导入SQL SERVER中
--表结构不存在可以使用
--启用Ad Hoc Distributed Queries:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
select * into serv_user_bak1 from
OpenRowSet('microsoft.jet.oledb.4.0','Excel 8.0;HDR=yes;database=c:\test.xls;','select * from [Sheet1$]')
---使用完成后,关闭Ad Hoc Distributed Queries:
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
-----------------------------------------------------------
--表结构存在可以使用
--启用Ad Hoc Distributed Queries:
exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure
insert into serv_user_bak1
SELECT * from
OpenRowSet('microsoft.jet.oledb.4.0','Excel 8.0;HDR=yes;database=c:\test.xls;','select * from [Sheet1$]')
---使用完成后,关闭Ad Hoc Distributed Queries:
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure
相关文档:
在一个数据表里,有3个字段,如下:
ID 自动增加,已建索引
TITLE nvarchar(255)
CONTENT ntext(16)
对title字段进行“like”查询,速度还行。但是要对content字段,进行“like”查询,速度很慢,不可 ......
declare @str varchar(50)
declare @i int
set @str = ''
set @i=0
while @i<50
begin
set @str = ......
[code=SQL][/code]
--语 句 功 能
--数据操作
SELECT --从数据库表中检索数据行和列
INSERT --向数据库表添加新数据行
DELETE --从数据库表中删除数据行
UPDATE --更新数据库表中的数据
--数据定义
CREATE TABLE --创建一个数据库表
DROP TABLE --从数据库中删 ......