excel ,access导入到sql2005

本文介绍如何使用SQL Server配置AdHocDistributedQueries参数来启用或禁用远程查询功能,并演示了从Excel和Access导入数据到SQL Server的方法。此外,还提供了查询远程SQL Server数据库的示例。

--启动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

转载于:https://www.cnblogs.com/-dawn/archive/2012/02/20/2360563.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值