Hi I have a temp table as shown below.
create table #Temp_Test
(
id int,
prod int,
total int
)
insert into #Temp_Test (id,prod,total)
values(1,10,20), (2,30,40), (3, 50,60)
I want to update id & prod in a single statement For example I want to update prod & total as 30 & 60 where id = 1.I am using the below query to do it :
update #Temp_Test
set prod = 30 , total = prod*2
where id = 1
The above query gives updates my prod as 30 & total as 20. instead of 60 which I expect. (Prod*2 is just an example, I could have different calculations here Prod*32 , Prod*7 etc).
what changes I need to do for it to work (I want to do it using a single query, I know how to make it work using multiple update queries) ?