Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2006-01-20 : 05:09:05
|
| I am trying to return the latest date in a stored procedure as shown below, but get the error 'incorrect syntax near @strLastDate'CREATE PROCEDURE spRB_GetLastDateBookingDates@strLastDate datetime OUTPUT ASSELECT max(BD_DateRequired) as @strLastDateFROM tblRB_BookingDatesGORETURN |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-20 : 05:13:09
|
Use thisSELECT @strLastDate = max(BD_DateRequired)FROM tblRB_BookingDates 'as' is use for defining alias for the column-----------------'KH' |
 |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2006-01-20 : 05:13:15
|
| SELECT @strLastDate = MAX(BD_DateRequired)-- Side comment, why preface @LastDate with @str if it isn't a string? |
 |
|
|
Pinto
Aged Yak Warrior
590 Posts |
Posted - 2006-01-20 : 05:17:33
|
Thank you, it's working now.re @str - I don't really know...... |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-01-20 : 06:31:41
|
>>re @str - I don't really know......Hereafter use Proper naming conventions MadhivananFailing to plan is Planning to fail |
 |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2006-01-20 : 08:32:45
|
quote: Originally posted by madhivanan Hereafter use Proper naming conventions 
Sounds like a sentence. |
 |
|
|
RickD
Slow But Sure Yak Herding Master
3608 Posts |
Posted - 2006-01-20 : 09:21:35
|
But the return value is a string.. |
 |
|
|
SamC
White Water Yakist
3467 Posts |
Posted - 2006-01-20 : 10:01:05
|
| DATETIME |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-01-20 : 18:45:48
|
What is the data type for BD_DateRequired ? datetime or varchar ?It should be a datetime if you are stroing date in it.If it is varchar or char, borrowing the famouse quote from Madhivananquote: Originally posted by madhivanan Hereafter use Proper naming conventions 
-----------------'KH' |
 |
|
|
|
|
|