Logo

INDENT

Updated 2023-11-10 14:59:56.100000

Syntax

SELECT [westclintech].[wct].[INDENT] (
  <@Text, nvarchar(max),>
 ,<@IndentChars, nvarchar(4000),>
 ,<@IndentLevels, int,>)

Description

Use the scalar function INDENT to place characters at the beginning of a string of text.

Arguments

@Text

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

@IndentLevels

the number of times that the @IndentChars is to be repeated at the beginning of @Text. The @IndentLevels argument can be an expression of types that are implicitly convertible to int.

@IndentChars

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

Return Type

nvarchar(max)

Remarks

The result of INDENT changes the width of the @Text. To add characters to the beginning of @Text while still limiting the overall width, use the PADLEFT function.

The @IndentChars are inserted after every CRLF in @Text.

Examples

select wct.INDENT('Now is the time for all' + wct.CRLF() + 'good men to come to the aid of their country', '>', 5);

This produces the following result.

{"columns":[{"field":"column 1"}],"rows":[{"column 1":""},{"column 1":">>>>>Now is the time for all"},{"column 1":">>>>>good men to come to the aid of their country"}]}