SQL Update a table from another table in a different database
Hello Experts;
I am trying to UPDATE a table named 'ORDERS' from another table also named 'ORDERS' in a different database. Both databases are on the same MS SQL 2008r2 server.
The Query is;
UPDATE SRSCustom1.dbo.ORDERS
SET
ORD_ID = SRSPRM2.dbo.ORDERS.ORD_ID
FROM
SRSPRM2.dbo.ORDERS
WHERE
ORD_ID = SRSPRM2.dbo.ORDERS.ORD_ID
AND
SRSCustom1.ORD_STATUS='O'
I'm getting an error;
"The objects "SRSCustom1.dbo.ORDERS" and "SRSPRM2.dbo.ORDERS" in the FROM clause have the same exposed names. Use correlation names to distinguish them."
When I add an Alias for the SRSPRM2.dbo.ORDERS table AS 'SRSPRM' I get an error;
"Incorrect syntax near SRSPRM".
Open in new window