Login     Register

        Contact Us     Search

XLeratorDB/strings Online Documentation

SQL Server PADLEFT function


PADLEFT

Updated: 30 April 2009


Use PADLEFT to place characters at the beginning of a string of text, when the length of the text is less than the specified width.
 Syntax
SELECT [wctString].[wct].[PADLEFT] (
   <@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.
·         If you want to indent @Text, consider using the INDENT function.
Examples
 
select wct.PADLEFT('abc'
,10
,' ')
 
This produces the following result
------------------
       abc
 

(1 row(s) affected)



Copyright 2008-2024 Westclintech LLC         Privacy Policy        Terms of Service