Ex: select dbo.zeros(’30’,4)
O Resultado será “0030”
create function zeros (@codigo Int, @quantidade int)
returns varchar(10)
as
begin
return ( replicate(‘0′,(@quantidade – len(cast(@Codigo as varchar)))) + cast(@Codigo as Varchar))
end
Scripts, Articles, Relevant for DBAs, Consultants, BI, Data Scientists and Developers
Ex: select dbo.zeros(’30’,4)
O Resultado será “0030”
create function zeros (@codigo Int, @quantidade int)
returns varchar(10)
as
begin
return ( replicate(‘0′,(@quantidade – len(cast(@Codigo as varchar)))) + cast(@Codigo as Varchar))
end