1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15:
create function [dbo].[fncGetRendiFormat] (@rendi int) returns nvarchar(7) begin declare @formati nvarchar(7) set @formati = ltrim(rtrim(cast(@rendi as nvarchar(7)))) select @formati = REPLICATE('0',7-len(@formati)) + @formati return @formati end