July 16, 2006 at 10:27 pm
column have to be the same for both 'AA' and 'BB'Kris
July 16, 2006 at 11:22 pm
UPDATE T1
SET ACT = T2.ACT
FROM Table T1
INNER JOIN Table T2 ON T1.Action = T2.Action AND T1.Code = T2.Code
WHERE T2.AC = 'AA' AND T1.AC = 'BB'
AND T1.ACT IS NULL -- not sure you want to have this last row in where clause
-- comment it if you need to update not only rows with NULL in ACT.
_____________
Code for TallyGenerator
July 17, 2006 at 3:30 pm
Sorry. I should have mentioned it's the same table.
Kris
July 17, 2006 at 3:51 pm
What Sergiy has given you will work for the same table. Just replace the work Table in the query (for both T1 and T2) with the same table name. This will create a self-join.
July 17, 2006 at 4:27 pm
I get the following error when I change the table names to be the same name.
The objects "Table1" and "Table1" in the FROM clause have the same exposed names. Use correlation names to distinguish them.
Kris
July 17, 2006 at 6:14 pm
Did you delete aliases?
What you need to do is to replace "Table" with real table name. Don't change anything else.
_____________
Code for TallyGenerator
July 17, 2006 at 8:03 pm
One of those days I think
Thanks for that, works perfectly.
Kris
Viewing 7 posts - 1 through 6 (of 6 total)
You must be logged in to reply to this topic. Login to reply