Click here to Skip to main content
15,910,980 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
In my scenario
SQL
UPDATE fine 
SET fine.name = RES.name
FROM fine INNER JOIN (select Query) AS RES ON fine .CODE=RES.CODE

It is not working.
Is this the right way?
Posted
Updated 21-Dec-12 0:40am
v3
Comments
__TR__ 21-Dec-12 5:32am    
Try
UPDATE LF
SET LF.name = RES.name
FROM fine AS LF INNER JOIN (select Query) AS RES ON LF.CODE=RES.CODE
josh-jw 21-Dec-12 5:39am    
its not working

1 solution

Here a CTE (Common Table Expression) should do the trick :

WITH SelectQuery AS
(
   SELECT CODE, name
   FROM ...
)

UPDATE fine 
SET fine.name = RES.name
FROM fine INNER JOIN SelectQuery AS RES ON fine.CODE=RES.CODE
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900