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
VN:F [1.1.6_502]
Rating: 4.0/5 (3 votes cast)
Share:
  • Digg
  • del.icio.us
  • Facebook
  • Google
  • DotNetKicks
  • LinkedIn
  • Live
  • MySpace
  • StumbleUpon
  • Technorati

Related posts:

  1. Write your first SQL Server CLR Stored Procedure
  2. T-SQL Find previous month
  3. Get Windows Edition information from SQL Server
  4. Winforms Calendar code – C#
  5. How to rename a column in mssql (t-sql)?