I feel like I am making this harder than it should be. So, let me provide more information so that it is clearer to anyone reading.
I have a view (GraceInfo) that was written by the DB Vendor. GraceInfo has the following fields:
This is what I would right in a query from your instructions:
SELECT Declare @GraceType varchar(10), @X interger@Y interger,CHANGEREASON_I AS Expr1
if Expr1 = "New Employee" then X := 14
else if Expr1 = "Update Status" then X:= 7;
For Y = 1 to X
If (Activityday <> "0") and (activityVac <> "0")
then GraceDate := dateadd(1 +d, startdate), Y=Y+1;
Can anyone help with the syntax?