Search code examples
sqlsql-server-2005t-sqlstored-proceduresjobs

GETDATE() in a T-SQL Job Step Command


I can't seem to get the GETDATE() syntax to work in a Job Step of type Transact-Sql Script. I put in the command as:

execute insertMostRecentUpdate 
@Data='Data', 
@Date=GETDATE()-1

But I get an "incorrect syntax near ')'" error when parsing or trying to run it. Any thoughts?


Solution

  • Try this:

    DECLARE @date DATETIME;
    SET @date = GETDATE()-1;
    
    execute insertMostRecentUpdate 
    @Data='Data', 
    @Date=@date;
    

    You cannot use GETDATE() as inline-function while calling a procedure.