Login     Register

        Contact Us     Search

XLeratorDB/strings Online Documentation

SQL Server PADRIGHT function


PADRIGHT

Updated: 30 April 2009


Use PADRIGHT to place characters at the end of a string of text, when the length of the text is less than the specified width.
 Syntax
SELECT [wctString].[wct].[PADRIGHT] (
   <@Text, nvarchar(max),>
 ,<@TotalWidth, int,>
 ,<@PaddingChar, nvarchar(1),>)
Arguments
@Text
the text to be padded. The @Text 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.
 
@PaddingChar
the character to be used for padding. The @PaddingChar argument can be of data types that are implicitly convertible to nvarchar or ntext.
 
Return Types
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
--------------------
1230000000
 
(1 row(s) affected)


Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service