CREATE FUNCTION pages_Allowed (@username varchar(35))
RETURNS varchar(30)
AS
BEGIN
-- Declare the return variable here
DECLARE @pages varchar(30)
DECLARE @PRvalidat tinyint,@PRdownload tinyint,@PRupload tinyint
-- Add the T-SQL statements to compute the return value here
select @PRvalidat=Rvalidate,@PRdownload=Rdownload,@PRupload=Rupload where Username=@username
select @pages
when @PRvalidate=1 and @PRdownload=1 and @PRupload=1 then @Pages='Admin'
when @PRvalidate=1 and @PRdownload=0 and @PRupload=0 then @pages='Validate Only'
when @PRvalidate=0 and @PRdownload=1 and @PRupload=0 then @pages='Download Only'
when @PRvalidate=1 and @PRdownload=0 and @PRupload=0 then @pages='Validate and Download'
End;
RETURN @pages
END
GO
I am getting an error as incorrect syntax near keyword at WHEN