I’m very very very new to using stored procedures and I’ve been tasked with updating one. Within the stored procedure, I need to update the following query:
update si_systemdetail
set status = 'Production'
where systemname in (select distinct systemname
from @systemHistory
where status = 'Production')`
Instead of updating the status to Production, I need to either update it to Production or Production w/o Application. The @systemHistory is a temp table that is populated by xml data and there is also a StatusHistory table that contains the value I need for the status Production w/o Application.
Basically I need to set status equal to either Production or Production w/o Application when systemname in this other table equals Production or Production w/o Application accordingly.
Can I even do this in one statement or do I need to make two statements, one to account for the Production and the other to account for the Production w/o Application?
If you need further information of if I haven’t explained this well enough, please let me know. I really want to learn how to do this.
TIA,
Tom
I think I was making this more difficult than it needed to be.
`update si_systemdetail
set status = ‘Production’
where systemname in (select distinct systemname from @systemHistory where newstatus = ‘Production’)
update si_systemdetail
set status = ‘Production w/o Appl’
where systemname in (select distinct systemname from @systemHistory where newstatus = ‘Production w/o Appl’)
if(@@error <> 0)
begin
rollback transaction
return 1
end`