Tech and a few other things RSS 2.0
# Wednesday, June 23, 2010


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:

  1. Put getdate() directly in your sql statement that resides in the stored procedure
  2. Pass a null if your table definition allows you to.
  3. Create a temp variable store the value of getdate() in that variable and pass in that variable through the datetime parameter.

Wednesday, June 23, 2010 11:41:51 AM (Central Standard Time, UTC-06:00)  #    Comments [0] - Trackback
SQL
Navigation
About the author/Disclaimer
        
My name is Ben Coffman. I'm in love with all things Mac yet I make a living in .NET. I view this as well rounded. When I turn the internet off I focus on family, random hobbies, and sharing moments in life.

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in any way.

© Ben Coffman

Archive
<September 2010>
SunMonTueWedThuFriSat
2930311234
567891011
12131415161718
19202122232425
262728293012
3456789
All Content © 2010,

Sign In