This code does not work:
conn.Execute("CREATE PROCEDURE mySuperProcedure
AS
BEGIN
IF GETDATE() >= DATEADD(hour," & waitHours & ",
DATEADD(minutes," & waitMinutes & ",'" & now & "')
BEGIN
blah blah...
END
END")
A SQL Agent Job runs this procedure every few seconds. It shall not do the "blah blah..." part until a certain time, but it does it every time because the IF statement returns true.
What could possibly be wrong? It makes no sense at all... :'(
not clear what you try to achieve but a quick look shows 2 syntax errors: ist MINUTE not minutes and you are missing a closing parenthesis in your dateadd
some questions that come to mind: