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的連接配接伺服器。