Comment utiliser une instruction du cas scalaire une fonction en SQL?

Je veux obtenir une valeur d'une fonction en utilisant une instruction case.
J'ai essayé ce qui suit, mais il ne fonctionne pas:

CREATE FUNCTION [FATMS].[fnReturnByPeriod]
(

    @Period INT

)
RETURNS int
AS
BEGIN

    SELECT CASE @Period 
             when 1 then 1
             when @Period >1 and @Period <=7 then 1
             when @Period >7 and @Period <=30 then 1
             when @Period >30 and @Period<=90 then 1
             when @Period >90 and @Period <=180 then 1
             when @Period >180 and @Period <=360 then 1
             else 0
           END

    RETURN @Period
END

OriginalL'auteur HAJJAJ | 2011-02-21