|
Posted by Hugo Kornelis on 06/06/06 20:56
On 6 Jun 2006 01:50:03 -0700, SQL Server wrote:
(snip)
>1) I tried declaring @retVal as a smalldatetime and get the error "Must
>declare the variable '@retVal'.'
Hi SQL Server,
And yet, that is exactly what you should do. Never convert unless you
have to.
The error message you got is not a result of declaring @retVal as a
smalldatetime, but a result of "something" that was off in the code when
you tried that. Unfortunately, you didn't post that version of the code,
so I can't tell you what went wrong. Maybe, if you still have tat
version archived, you could post it here?
Meanwhile, try if this works:
CREATE FUNCTION dbo.test (@Group varchar(50))
RETURNS smalldatetime
AS
BEGIN
DECLARE @retVal smalldatetime
SELECT @retVal = MIN([date])
FROM dbo.t_master_schedules
WHERE event_id = 13
AND group_ = @Group
RETURN @retVal
END
--
Hugo Kornelis, SQL Server MVP
[Back to original message]
|