excel ,access导入到sql2005

--启动Ad Hoc Distributed Queries

exec sp_configure 'show advanced options',1
reconfigure
exec sp_configure 'Ad Hoc Distributed Queries',1
reconfigure

--导入excel
select * into qingkao from
     openrowset('microsoft.jet.oledb.4.0','excel 5.0;hdr=yes;database=d:1.xls',sheet1$)

--导入access

select * into aaa from
opendatasource( 'Microsoft.Jet.OLEDB.4.0','Data Source="d:SpiderResult.mdb";Jet OLEDB:Database Password=')...[content]

--查询远程数据库(mssql)

select *  from openrowset('sqloledb','192.168.1.108,1046';'sa';'123#@!',[testdatabase].dbo.corporation) where spctypeid=2 or spctypeid=3

--关闭
exec sp_configure 'Ad Hoc Distributed Queries',0
reconfigure
exec sp_configure 'show advanced options',0
reconfigure

查询和修改差不多,既然可以从excel,远程数据查数据,就是可以改数据。把oprenrowset、opendatasource那段当成一个表就行了!

 

http://download.microsoft.com/download/2/4/3/24375141-E08D-4803-AB0E-10F2E3A07AAA/AccessDatabaseEngine_x64.exe

posted @ 2012-02-20 21:58  一杯晨光  阅读(301)  评论(0编辑  收藏  举报