1、查询Access中数据的方法:
select * from OpenRowSet('microsoft.jet.oledb.4.0',';database=c:/db2.mdb','select * from serv_user')
或select * from OpenDataSource('Microsoft.Jet.OLEDB.4.0','Data Source="c:/DB2.mdb";User ID=Admin;Password=')
2、从SQLServer向Access写数据:
insert into OpenRowSet('microsoft.jet.oledb.4.0',';database=c:/db2.mdb','select * from Accee表')
select * from SQLServer表
或用BCPmaster..xp_cmdshell'bcp "serv-htjs.dbo.serv_user" out "c:/db3.mdb" -c -q -S"." -U"sa" -P"sa"'
上面的区别主要是:OpenRowSet需要mdb和表存在,BCP会在不存在的时候生成该mdb
3、从Access向SQLServer写数据:
有了上面的基础,这个就很简单了
insert into SQLServer表 select * from
OpenRowSet('microsoft.jet.oledb.4.0',';database=c:/db2.mdb','select * from Accee表')
或用BCP
master..xp_cmdshell'bcp "serv-htjs.dbo.serv_user" in "c:/db3.mdb" -c -q -S"." -U"sa" -P"sa"'
4、删除Access数据:
delete from OpenRowSet('microsoft.jet.oledb.4.0',';database=c:/db2.mdb','select * from serv_user')
where lock=0
5、修改Access数据:
update OpenRowSet('microsoft.jet.oledb.4.0',';database=c:/db2.mdb','select * from serv_user')
set lock=1