Error Readout:Incorrect syntax near ')'
The Problem:When I was trying to pass in
getdate() as a parameter to execute a stored procedure i got the above error.
Example:exec dbo.storedProcedure
@param1 = '8D8DF077-7491-491B-AFA2-8F088821A073',
@param2 = '8D8DF077-7491-491B-AFA2-8F088821A073',
@param3 = 'Market: SAP 4 Eva',
@param4 = getdate()
The Solution:A sql execute statement can't pass a function such as
getdate()
in through a parameter. To fix this either:
- Put getdate() directly in your sql statement that resides in the stored procedure
- Pass a null if your table definition allows you to.
- Create a temp variable store the value of getdate() in that variable and pass in that variable through the datetime parameter.