Logo

PADRIGHT

Updated 2023-11-09 21:29:17.477000

Syntax

SELECT [westclintech].[wct].[PADRIGHT] (
  <@Text, nvarchar(max),>
 ,<@TotalWidth, int,>
 ,<@PaddingChar, nvarchar(1),>)

Description

Use the scalar function PADRIGHT to place characters at the end of a string of text, when the length of the text is less than the specified width.

Arguments

@PaddingChar

the character to be used for padding. The @PaddingChar argument can be of data types that are implicitly convertible to nvarchar or ntext.

@TotalWidth

the minimum length of the result, including padding. The @Totalwidth argument can be an expression of types that are implicitly convertible to int.

@Text

the text to be padded. The @Text argument can be of data types that are implicitly convertible to nvarchar or ntext.

Return Type

nvarchar(max)

Remarks

If LEN(@Text) = @TotalWidth, then @Text is returned.

If @TotalWidth < 0, then an error is returned.

If @TotalWidth is NULL, then an error is returned.

If @PaddingChar is null, then SPACE is used.

If @PaddingChar is blank, then SPACE is used.

Examples

select wct.PADRIGHT('123', 10, '0');

This produces the following result.

{"columns":[{"field":"column 1","headerClass":"ag-right-aligned-header","cellClass":"ag-right-aligned-cell"}],"rows":[{"column 1":"1230000000"}]}