sql server - Creating a stored procedure to update a row in a SQL database using data from the previous row -
good afternoon all,
i have database used track production on assembly line.
effectively finished product show each stage
of production line , serial number of in it.
i have created stored procedure retrieve , display data, struggling move machine stage 1
stage 2
, stage 2
stage 3
etc... table simple, contains following rows:
stage_id (pk, int, not null) build_id(fk, int, null)
effectively, want build stored procedure move value of build_id
stage_id = 1
stage_id = 2
.
any idea how this?
thanks
update stagetable set build_id = (select build_id stagetable stage_id = 1) stage_id = 2
if need procedure this
create procedure sp_movestage(@from int, @to int) update stagetable set build_id = (select build_id stagetable stage_id = @from) stage_id = @to
and execute
exec sp_movestage 1, 2
Comments
Post a Comment