UPDATE VS4TMPS SET TMPSTJStTSpdStep=1 WHERE TMPSTJStTSpdStep=0 or TMPSTJStTSpdStep is null
GO
UPDATE VS4TMPS SET TMPSTJStLn=1 WHERE TMPSTJStLn=0 or TMPSTJStLn is null
GO
UPDATE VS4TMPS SET TMPSTSecCode=
(SELECT VS4TMRPStepName.TSepTSecCode
FROM VS4TMRPStepName RIGHT JOIN VS4TJobMethod ON VS4TMRPStepName.TSepCode = VS4TJobMethod.TJStTSepCode
WHERE VS4TMPS.TMPSTJStTJbMTJobNo=VS4TJobMethod.TJStTJbMTJobNo AND VS4TMPS.TMPSTJStTJbMLn=VS4TJobMethod.TJStTJbMLn AND VS4TJobMethod.TJStTSpdStep=1 AND VS4TJobMethod.TJStln=1)
WHERE TMPSTSecCode='' or TMPSTSecCode is null
GO