TSQL: fnPadLeft: fills up a string with padChar from left

— Description: fills up a string  with @len  @padChar+@var from left

— Example: SELECT dbo.[fnPadLeft](‘1’, ‘0’, 3) returns ‘001’

— =============================================

CREATE Function[dbo].[fnLBCustomPadLeft]

(@varvarchar(max),

@padCharchar(1)=‘ ‘,

@lenint)

returnsvarchar(max)

as
begin

return replicate(@PadChar,@lenLen(@var))+@var

end

 

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s