Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Creating function
Message
 
 
À
08/02/2004 05:21:53
Larry Santos
Local Data System
Philippines
Information générale
Forum:
Microsoft SQL Server
Catégorie:
Stored procedures, Triggers, UDFs
Divers
Thread ID:
00875246
Message ID:
00875273
Vues:
19
Try
RETURN RIGHT(REPLICATE('0', 5) + @val, 5)
You may add the second parameter to UDF for the return size to make function more generic.

>Hi,
>
>i have code and is return zero, what do i miss to my code?
>
>alter FUNCTION RET_xxx (@val varchar(20))
>returns varchar
>AS
>begin
>	declare @ret varchar(20)
>	IF LEN(@val) = 1
>		set @ret= '0000'+@val
>	ELSE IF LEN(@val) = 2
>		set @ret=  '000'+@val
>	ELSE IF LEN(@val) = 3
>		set @ret=  '00'+@val
>	ELSE IF LEN(@val) >= 4
>		set @ret=  '0'+@val
>	RETURN(@ret)
>end
--sb--
Précédent
Répondre
Fil
Voir

Click here to load this message in the networking platform