Skip to content

Commit 0bcd5ff

Browse files
committed
Added PadRight article
1 parent 0ebcc7a commit 0bcd5ff

File tree

2 files changed

+52
-0
lines changed

2 files changed

+52
-0
lines changed
Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,51 @@
1+
# String_PadRight
2+
3+
`String_PadRight` returns a new string that left-aligns the characters in the `source` string by padding them on the right with a specified `paddingChar` Unicode character, for a specified total length.
4+
5+
```csharp
6+
String_PadRight (
7+
@source NVARCHAR (MAX),
8+
@totalWidth INT,
9+
@paddingChar NVARCHAR (1)
10+
)
11+
RETURNS INT
12+
```
13+
14+
## Parameters
15+
16+
- **source**: The source string.
17+
- **totalWidth**: The number of characters in the resulting string, equal to the number of original characters plus any additional padding characters.
18+
- **paddingChar**: A Unicode padding character.
19+
20+
## Returns
21+
22+
- A new string that is equivalent to the `source` string, but right-aligned and padded on the left with as many paddingChar characters as needed to create a length of `totalWidth`.
23+
- If `totalWidth` is less than the length of the `source` string, the method returns a reference to the existing instance.
24+
- If `totalWidth` is equal to the length of the `source` string, the method returns a new string that is identical to the `source` string.
25+
26+
## Example
27+
28+
```csharp
29+
SELECT SQLNET::String_PadRight('This is a String.', 20, '.')
30+
SELECT SQLNET::String_PadRight('This is a String.', 10, '.')
31+
```
32+
33+
# String_PadRight4k
34+
35+
It is equivalent to `String_PadRight` except no NVARCHAR(MAX) parameters; it can be used when input data will never be over 4000 characters as this function offers better performance.
36+
37+
```csharp
38+
String_PadRight4k (
39+
@source NVARCHAR (4000),
40+
@totalWidth INT,
41+
@paddingChar NVARCHAR (1)
42+
)
43+
RETURNS INT
44+
```
45+
46+
## Example
47+
48+
```csharp
49+
SELECT SQLNET::String_PadRight4k('This is a String.', 20, '.')
50+
SELECT SQLNET::String_PadRight4k('This is a String.', 10, '.')
51+
```

docs2/pages/documentations/string/string.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -33,3 +33,4 @@ Represents text as a sequence of UTF-16 code units.
3333
| [String_Length(source)](/string-length) | Returns the number of characters in the specified string. | [Try it]()|
3434
| [String_Occurrences(source, searchValue, isCaseSensitive)](/string-occurrences) | Returns the number of occurrences in the specified string. | [Try it]()|
3535
| [String_PadLeft(source, totalWidth, paddingChar)](/string-padleft) | Returns a new string that right-aligns the characters in this instance by padding them on the left with a specified Unicode character, for a specified total length. | [Try it]()|
36+
| [String_PadRight(source, totalWidth, paddingChar)](/string-padright) | Returns a new string that left-aligns the characters in this instance by padding them on the right with a specified Unicode character, for a specified total length. | [Try it]()|

0 commit comments

Comments
 (0)