udf function not returnint proper value
-
mercredi 9 mars 2011 15:11
I am trying to create a simple function to return a string value but the problem it returns only 1 char instead of the full work
[code]
-- Declare the return variable here
DECLARE @mois nvarchar(10)
-- Add the T-SQL statements to compute the return value hereRETURN CASE @inMth
WHEN 'Jan' THEN 'Janvier'
WHEN 'Feb' THEN 'Fevrier'
WHEN 'Mar' THEN 'Mars'
WHEN 'Apr' THEN 'Avril'
WHEN 'May' THEN 'Mai'
WHEN 'Jun' THEN 'Juin'
WHEN 'Jul' THEN 'Juillet'
WHEN 'Aug' THEN 'Aout'
WHEN 'Sep' THEN 'Septembre'
WHEN 'Oct' THEN 'Octobre'
WHEN 'Nov' THEN 'Novembre'
WHEN 'Dec' THEN 'Decembre'
END-- Return the result of the function
RETURN @mois
[/code]when I run the following I get J as the returm value
select
@m= dbo.udf_TranslateMonthToFrench('Jan')
print @mThanks
Toutes les réponses
-
vendredi 1 avril 2011 19:10
Hi Alabil,
Please could you post the whole function declaration, including the function header and the line where you declare @inMth
Thanks.
Peter Carter-Greenan http://sqlserverdownanddirty.blogspot.com/ -
jeudi 5 mai 2011 15:20
make sure the returned type is right
RETURNS NVARCHAR(10)
- Proposé comme réponse StefDBA jeudi 5 mai 2011 15:21
- Marqué comme réponse Mr. WhartyMicrosoft Community Contributor, Moderator vendredi 25 mai 2012 04:39

