December 5, 2007 at 9:08 am
I have procedure which takes dates in the form of varchar fields, but when I pass the dates as I get an error
ALTER procedure P_REALTYTAX (@DATE1 varchar(20), @DATE2 varchar(20))
as
EXEC dbo.[P_REALTYTAX] ('2007-12-05', '2007-12-05')
EXEC dbo.[P_REALTYTAX] ('11/07/07', '11/07/06')
I get the following error
Server: Msg 170, Level 15, State 1, Line 1
Line 1: Incorrect syntax near '2007'.
Thanks
Sri
December 5, 2007 at 11:02 am
you shouldn't use varchar fields to carry/pass datetime fields.
your procedure should accept datetime fields instead:
ALTER procedure P_REALTYTAX (@DATE1 datetime, @DATE2 datetime)
as
...
to test whether this would work, simply try sticking the values in a datetime field:
declare @mydate datetime
set @mydate='2007-12-05'
print @mydate
set @mydate='11/07/07'
print @mydate
results:
Dec 5 2007 12:00AM
Nov 7 2007 12:00AM
Lowell
December 6, 2007 at 12:13 am
The problem is that you should not use parenthesis around parameters for stored procedures. 😉
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply