1、查詢(xún)Access中數(shù)據(jù)的方法:
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=')...serv_user
2、從SQLServer向Access寫(xiě)數(shù)據(jù):
insert into OpenRowSet('microsoft.jet.oledb.4.0',';database=c:\db2.mdb','select * from Accee表')
select * from SQLServer表
或用BCP
master..xp_cmdshell'bcp "serv-htjs.dbo.serv_user" out "c:\db3.mdb" -c -q -S"." -U"sa" -P"sa"'
上面的區(qū)別主要是:OpenRowSet需要mdb和表存在,BCP會(huì)在不存在的時(shí)候生成該mdb
3、從Access向SQLServer寫(xiě)數(shù)據(jù):有了上面的基礎(chǔ),這個(gè)就很簡(jiǎn)單了
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數(shù)據(jù):
delete from OpenRowSet('microsoft.jet.oledb.4.0',';database=c:\db2.mdb','select * from serv_user')
where lock=0
5、修改Access數(shù)據(jù):
update OpenRowSet('microsoft.jet.oledb.4.0',';database=c:\db2.mdb','select * from serv_user')
set lock=1