I am trying to JOIN two different databases and am getting an error that I have not seen before. The SQL joins the database PDX_SAP_USER
to asagdwpdx_prod
.
The strange thing is that in the code below, if I exclude the table dbo.VW.PO_HEADER H
and only include dbo.VW_PO_ITEM P
, the query works fine, but the JOIN I need is on between the H and G tables. It's when I include the PO Header table the issue arises.
The error message is:
Msg 7202, Level 11, State 2, Line 2
Could not find server 'PDX_SAP_USER' in sys.servers. Verify that the correct server name was specified. If necessary, execute the stored procedure sp_addlinkedserver to add the server to sys.servers.
The SQL code is:
SELECT
G.order_no,
G.order_status,
G.cst_order_no,
H.PO_NUMBER,
P.PO_ITEM_NUMBER,
P.DEL_INDICATOR
FROM
(SELECT
order_no,
order_status,
cst_order_no
FROM
asagdwpdx_prod.dbo.SimoxOrder1
UNION ALL
SELECT
order_no,
order_status,
cst_order_no
FROM
asagdwpdx_prod.dbo.SimoxOrder2
UNION ALL
SELECT
order_no,
order_status,
cst_order_no
FROM
asagdwpdx_prod.dbo.SimoxOrder3) G
JOIN
PDX_SAP_USER.dbo.VW.PO_HEADER H ON G.order_no = H.AHAG_NUMBER
JOIN
PDX_SAP_USER.dbo.VW_PO_ITEM P ON H.PO_NUMBER = P.PO_NUMBER
WHERE
G.order_status = '90'
Thanks.
I think PDX_SAP_USER.dbo.VW.PO_HEADER
is supposed to be PDX_SAP_USER.dbo.VW_PO_HEADER
. The extra period is making SQL Server think you're using 4-part naming to try to access a linked server.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.