Home Forums SQL Server 2008 T-SQL (SS2K8) CTE with Linked Server: Mulitpart Identifier could not be bound RE: CTE with Linked Server: Mulitpart Identifier could not be bound

  • Once again this morning, the job failed and has continued to fail. I tried the below as well as a try catch and both are yielding the same result. I'm am talking with our SAP analyst in regards to those tables as it appears that it the error is coming from that server.

    Lynn Pettis (7/21/2014)


    Just a thought, but I was wondering if the following would work:

    SELECT WorkOrder, TakTime

    INTO

    [plc].[TaktTime]

    from openquery([SAPETL],'

    WITH TaktValues ([Counter], NODE, PLNNR) AS

    (

    SELECT

    MAX(plpo1.ZAEHL) AS [Counter], MAX(plpo1.PLNKN) AS NODE, plpo1.PLNNR

    FROM

    [ERP].[erp].PLPO plpo1

    GROUP BY plpo1.PLNNR

    )

    SELECT

    s022.AUFNR AS WorkOrder,

    (CASE

    WHEN plpo.SPLIM = 0 THEN 0

    ELSE plpo.VGW01/plpo.SPLIM

    END) AS TaktTime

    FROM

    [ERP].[erp].S022 s022

    INNER JOIN

    [ERP].[erp].AFPO afpo on afpo.AUFNR = s022.AUFNR

    INNER JOIN

    [ERP].[erp].AFKO afko on afko.AUFNR = s022.AUFNR

    INNER JOIN

    [ERP].[erp].PLPO on plpo.PLNNR = afko.PLNNR

    INNER JOIN

    TaktValues ON plpo.PLNNR = TaktValues.PLNNR

    AND plpo.ZAEHL = TaktValues.[Counter]

    AND plpo.PLNKN = TaktValues.NODE

    WHERE

    s022.AUFNR IN (SELECT DISTINCT WorkOrder FROM plc.AlarmData)

    ORDER BY

    s022.AUFNR DESC

    ');