T-SQL Pass GETDATE() as a parameter for stored procedure
Filed in SQL on Jun.24, 2009
When you pass getdate() function as a parameter directly to a stored procedure, you will get an error: Incorrect syntax near ‘)’.
EXEC sp_GetProject GETDATE() Error: Msg 102, Level 15, State 1, Line 1 Incorrect syntax near ')'.
To avoid this, you will need to create a variable and pass it to the stored procedure. Like this:
DECLARE @dt DATETIME; SET @dt=GETDATE(); EXEC sp_GetProject @dt
Related posts:























Leave a Reply
You must be logged in to post a comment.