You are here: Re: Question about returning a smalldatetime from a Function « MsSQL Server « IT news, forums, messages
Re: Question about returning a smalldatetime from a Function

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

 

Navigation:

[Reply to this message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация