Hi all,I have a table with 5 columns: Job Id (Just an index), Last Run (Date), Next Run (Date), ScheduleMinutes (integer) and IsActive (Bit). Whenever I call my update-SP it should add the ScheduleMinutes to LastRun and store it as NextRun. This works fine: Update dbo.Scheduler SET LastRun = @LastRun, NextRun = DATEADD(n, ScheduleMinutes, @LastRun) WHERE JobID = @JobID
Now I need to set also IsActive: If ScheduleMinutes is 0, IsActive should be set to 0, otherwise it should not be modified. I know how to do IF-Clauses for input parameters, but how do I combine it with a value from a row? I tried it this way but that's wrong: IF dbo.Scheduler.ScheduleMinutes = 0 BEGIN Update dbo.Scheduler SET LastRun = @LastRun, IsActive = 0 Where JobID = @JobID END ELSE BEGIN Update dbo.Scheduler SET LastRun = @LastRun, NextRun = DATEADD(n, ScheduleMinutes, @LastRun) WHERE JobID = @JobID END