Another developer created a stored procedure that is set up to run as a sql job each month. It takes one parameter of datetime. When I try to invoke it in the job or in just a query window I get an error Incorrect syntax near ')'. The call to execute it is:
exec CreateHeardOfUsRecord getdate()
When I give it a hard coded date like exec CreateHeardOfUsRecord '4/1/2010' it works fine. Any idea why I can’t use getdate() in this context? Thanks.
Parameters passed with Exec must either be constants or variables. GetDate() is classed as a function. You need to declare a variable to hold the result of GetDate(), then pass it to the stored procedure.