rpad
rpad(@txt, @len)
returns a string whose length is @len
. If len(@txt)
is smaller than @len
, the returned string is @txt
whose right side is padded with spaces, otherwise, @txt
is truncated on the right side.
create or alter function dbo.rpad(
@txt varchar(max),
@len int
) returns varchar(max)
as begin
return left(coalesce(@txt, '') + space(4000), @len)
end;
go
rremove
rremove(@string, @len)
removes @len
characters from the right side of @string
and returns the resulting value.
If @len
is greater than len(@string)
, an empty string is returned.
create or alter function dbo.rremove(
@txt nvarchar(max),
@len int
) returns nvarchar(max)
as begin
if len(@txt) < @len return ''
return left(@txt, len(@txt) - @len)
end;
go