Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase ««123»»

CTE with Linked Server: Mulitpart Identifier could not be bound Expand / Collapse
Author
Message
Posted Monday, July 21, 2014 10:41 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 8:50 AM
Points: 6,846, Visits: 13,384
I don't think it will help at all to know the linked server that is referenced.

The OP should try a
SELECT TOP 1 AUFNR FROM afpo
SELECT TOP 1 AUFNR FROM afko
SELECT TOP 1 AUFNR FROM s022

to verify which one fails.

Then use SELECT * FROM the_table_in_question

Finally, take a Baseball bat and practice at the "Submit-And-Pray"-Dptmt....




Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Post #1594680
Posted Monday, July 21, 2014 10:53 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, July 29, 2014 4:14 PM
Points: 12, Visits: 61
Once again I apologize.

All synonyms are pointed to the same server and created as follows. Of course replacing the appropriate table name where required.

CREATE SYNONYM [etl].[AFKO] FOR [SAPETL].[ERP].[erp].[AFKO]
Post #1594686
Posted Monday, July 21, 2014 10:54 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 8:50 AM
Points: 6,846, Visits: 13,384
Did you try what I proposed to find the table in question?



Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Post #1594690
Posted Monday, July 21, 2014 11:00 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Tuesday, July 29, 2014 4:14 PM
Points: 12, Visits: 61
Yes, all queries went through. The interesting part is the query I am using is working. but its intermittent.
Post #1594696
Posted Monday, July 21, 2014 11:03 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 9:15 AM
Points: 20,861, Visits: 32,888
Issues.

One, you only posted the DDL for one synonym, but enough on that.
Two, it is looking like the "tables" may actually be views not actual tables.
Three, and I may be wrong here, but you are going to be pulling the data from all the tables referenced across your network to the server running the query where the respective joins and filtering will then be completed.

At this point we really can't do much until you provide the underlying DDL for objects referenced in the query.



Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1594700
Posted Monday, July 21, 2014 11:24 AM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 8:50 AM
Points: 6,846, Visits: 13,384
Since it'll break all of a sudden and then work as usual I'd add a TRY CATCH block to the sproc where the CATCH block would call a separate sproc that would perform the tests I posted, again wrapped in a separate TRY CATCH block to identify the one that fails.

Remember: If you're forced to work against the three-letter-word-that-must-not-be-named you'll have to add double and triple checks down to the level of pure stupidity to lower the risk of your code crashes due to changes on their side...
Been there. Done that. Glad I left it behind me. Still have nightmares occasionally.




Lutz
A pessimist is an optimist with experience.

How to get fast answers to your question
How to post performance related questions
Links for Tally Table , Cross Tabs and Dynamic Cross Tabs , Delimited Split Function
Post #1594721
Posted Monday, July 21, 2014 11:25 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: 2 days ago @ 3:20 PM
Points: 18,064, Visits: 16,099
ChrisM@home (7/21/2014)
Lynn Pettis (7/21/2014)
DevNate (7/21/2014)
Lined server is connected via Symbols.


So you are saying the Linked Server is hidden by using a synonym? Well, not obvious from what you posted. What is the synonym used so we can tell which table in the query is actually a linked server.

Can you confirm with your DBA that this is actually the case? I can't see how this object naming convention of schema.linkedserver can work.


The beauty there is that the linked server is obfuscated through the use of synonyms. So in this case, they are referencing schema.synonym.

Obfuscating it like what has been done is only going to compound problems when trying to troubleshoot it.




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #1594722
Posted Monday, July 21, 2014 11:28 AM


SSCoach

SSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoachSSCoach

Group: General Forum Members
Last Login: 2 days ago @ 3:20 PM
Points: 18,064, Visits: 16,099
Lynn Pettis (7/21/2014)
Issues.

Three, and I may be wrong here, but you are going to be pulling the data from all the tables referenced across your network to the server running the query where the respective joins and filtering will then be completed.



That is the way it appears to me as well. That is a recipe for problems.

Far more efficient to perform the join query on the remote server and then pull the resultant data across if you truly must pull it across to a different server.

That can be done in many different ways. In the end, just join the data on the source server.




Jason AKA CirqueDeSQLeil
I have given a name to my pain...
MCM SQL Server, MVP


SQL RNNR

Posting Performance Based Questions - Gail Shaw
Post #1594723
Posted Monday, July 21, 2014 11:34 AM


SSC-Insane

SSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-InsaneSSC-Insane

Group: General Forum Members
Last Login: Today @ 9:15 AM
Points: 20,861, Visits: 32,888
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
');





Lynn Pettis

For better assistance in answering your questions, click here
For tips to get better help with Performance Problems, click here
For Running Totals and its variations, click here or when working with partitioned tables
For more about Tally Tables, click here
For more about Cross Tabs and Pivots, click here and here
Managing Transaction Logs

SQL Musings from the Desert Fountain Valley SQL (My Mirror Blog)
Post #1594726
Posted Monday, July 21, 2014 11:42 AM
Ten Centuries

Ten CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen CenturiesTen Centuries

Group: General Forum Members
Last Login: Yesterday @ 2:07 AM
Points: 1,037, Visits: 7,025
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
');




That's the one. EXECUTE() AT linkedserver is good too.



Low-hanging fruit picker and defender of the moggies





For better assistance in answering your questions, please read this.




Understanding and using APPLY, (I) and (II) Paul White

Hidden RBAR: Triangular Joins / The "Numbers" or "Tally" Table: What it is and how it replaces a loop Jeff Moden
Post #1594731
« Prev Topic | Next Topic »

Add to briefcase ««123»»

Permissions Expand / Collapse