Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

SQL Update query with sub-query

Status
Not open for further replies.

UnleashThePain

Programmer
Oct 23, 2006
16
NL
UPDATE [database].dbo.PAL
SET CLIENT_ID = (SELECT CLIENT_ID
FROM ORDERTEMP
WHERE TAG_ID IN
(SELECT TAG_ID
FROM ORDERTEMP
WHERE ORDERTEMP.TAG_ID = ORDER.TAG_ID))

When I execute the query in MS-SQL the error 'Timeout Expired' is displayed

Can anyone help me with making the query work? I want to update all fields of table ORDER except the key field (TAG_ID) with data from table ORDERTEMP.

-----------------------------------------
>>>Fornicate Under Command of the King<<<
 
First question is how is PAL and OrderTemp related?
 
Sorry about that! PAL = ORDER.

-----------------------------------------
>>>Fornicate Under Command of the King<<<
 
Try this (not tested)
Code:
UPDATE [database].dbo.ORDER
SET CLIENT_ID = ORDERTEMP.CLIENT_ID
FROM [database].dbo.ORDER
INNER JOIN ORDERTEMP
ON [database].dbo.ORDER.TAG_ID = ORDERTEMP.TAG_ID
djj
 
Thanks DJJ,

I didn't know it whas that easy!

Unleash

-----------------------------------------
>>>Fornicate Under Command of the King<<<
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top