我有一个oracle 8数据库,我想从中获取数据到SQL Server 2005.如果SQL Server 2005上的表为空,则以下语句可以正常工作。如果我运行,让我们说一个条目丢失,它就不起作用。如果有任何其他信息有用,请告诉我!
SELECT wdmsoracle.NO
FROM (Select * from OPENQUERY(msch, 'select
actu.NO
, actu.ANNOSEQUENT
, replace(replace(dm.descript, ''Generated by modification request '', ''Modification request''), ''Pseudo ECR for WDMS-SAP interface'', ''New Drawing'')
, actu.APPRDATE
, actu.MADEDATE
, actu.MAINDRW
, actu.DESIGNGRP
, actu.ITEMID
, actu.ISSUE
, actu.DESCRIPT
, actu.DESCRIPT2
, dr.PRODUCTCODE
, mpaths.webpath as asdasd
, vpaths.webpath
FROM
WDDRAWACTU actu
, wddraw dr
, wddvfilesiss vfiles
, wddvpaths vpaths
, wddmfiles mfiles
, wddmpaths mpaths
, wdanno dm
WHERE actu.apprdate >= to_date(''01-01-05'',''dd-mm-yy'')
and actu.itemid = dr.itemid (+)
and actu.issue = dr.issue (+)
and actu.annosequent = dm.sequent (+)
and actu.itemid = vfiles.itemid (+)
and actu.issue = vfiles.issue (+)
and vfiles.pathid = vpaths.pathid
and actu.annosequent = mfiles.sequent (+)
and mfiles.pathid = mpaths.pathid')) as wdmsoracle
Where NOT EXISTS (
SELECT wdmsoracle.NO
FROM [DesignMessage_Workflow].[dbo].[WDMS] wdms, (Select * from OPENQUERY(msch, 'select
actu.NO
FROM
WDDRAWACTU actu
WHERE actu.apprdate >= to_date(''01-01-05'',''dd-mm-yy'')')) as wdmsoracle
WHERE wdms.NO = wdmsoracle.NO)
答案 0 :(得分:1)
在this website的帮助下,我能够自己解决这个问题:
SELECT wdmsoracle.NO
FROM (Select * from OPENQUERY(msch, 'select
actu.NO
, actu.ANNOSEQUENT
, replace(replace(dm.descript, ''Generated by modification request '', ''Modification request''), ''Pseudo ECR for WDMS-SAP interface'', ''New Drawing'')
, actu.APPRDATE
, actu.MADEDATE
, actu.MAINDRW
, actu.DESIGNGRP
, actu.ITEMID
, actu.ISSUE
, actu.DESCRIPT
, actu.DESCRIPT2
, dr.PRODUCTCODE
, mpaths.webpath as asdasd
, vpaths.webpath
FROM
WDDRAWACTU actu
, wddraw dr
, wddvfilesiss vfiles
, wddvpaths vpaths
, wddmfiles mfiles
, wddmpaths mpaths
, wdanno dm
WHERE actu.apprdate >= to_date(''01-01-05'',''dd-mm-yy'')
and actu.itemid = dr.itemid (+)
and actu.issue = dr.issue (+)
and actu.annosequent = dm.sequent (+)
and actu.itemid = vfiles.itemid (+)
and actu.issue = vfiles.issue (+)
and vfiles.pathid = vpaths.pathid
and actu.annosequent = mfiles.sequent (+)
and mfiles.pathid = mpaths.pathid')) as wdmsoracle
Where NOT EXISTS (
SELECT wdms.NO
FROM [DesignMessage_Workflow].[dbo].[WDMS] wdms
WHERE wdms.NO = wdmsoracle.NO)