天天看点

怎样用一条词句操作access和sqlserver(是内网上其它一台电脑)两个数据库?

2、一条sql运行两个数据库:

如果公司数据库和超市数据库的用户密码都一致,那么可以:

insert into 超市table select * from  nkrxdata.safecontrol.dbo.公司table

where 。。。。。。

如果公司数据库和超市数据库的用户密码不一致,那么可以:

insert into超市table select * from openrowset('sqloledb', 'nkrxdata';'safecontrol';'200000',  'select * from safecontrol.dbo.公司table  where。。。。。。') where 条件是子查询,表t_operaterecord中的修改记录id

删除时候的sql:

delete from 超市table where 主键 in (select主键from openrowset('sqloledb', 'nkrxdata';'safecontrol';'200000',  'select * from safecontrol.dbo.公司table  where。。。。。。')) where 条件是子查询,表t_operaterecord中的修改记录id

请参考:

select *

from opendatasource(

          'sqloledb',

          'data source=dkserver2;user id=sa;password=perfect'

                   ).winmzgl.dbo.z_kszd a,

openrowset('microsoft.jet.oledb.4.0',

   'd:/mzzd.mdb';'admin';'', z_yszd) b

where a.ksdh=b.ksdh

我觉得,如果是经常性操作,不如将他加为sql的连接服务器。