Skip to content

Commit 5a32133

Browse files
committed
Added String Occurrences article
1 parent 60ae52a commit 5a32133

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
# String_Occurrences
2+
3+
`String_Occurrences` returns the number of occurrences of `searchValue` in the `source` string.
4+
5+
```csharp
6+
String_Occurrences (
7+
@source NVARCHAR (MAX),
8+
@searchValue NVARCHAR (MAX),
9+
@isCaseSensitive BIT
10+
)
11+
RETURNS INT
12+
```
13+
14+
## Parameters
15+
16+
- **source**: The source string.
17+
- **searchValue**: The string to search within the source string.
18+
- **isCaseSensitive**: 0 to ignore case during the comparison; otherwise, 1.
19+
20+
## Returns
21+
22+
The number of characters in the `source` string.
23+
24+
## Example
25+
26+
```csharp
27+
SELECT SQLNET::String_Occurrences('This is a String.', 's', 0)
28+
SELECT SQLNET::String_Occurrences('This is a String.', 's', 1)
29+
```
30+
31+
# String_Occurrences4k
32+
33+
It is equivalent to `String_Occurrences` except no NVARCHAR(MAX) parameters; it can be used when input data will never be over 4000 characters as this function offers better performance.
34+
35+
```csharp
36+
String_Occurrences4k (
37+
@source NVARCHAR (4000),
38+
@searchValue NVARCHAR (4000),
39+
@isCaseSensitive BIT
40+
)
41+
RETURNS INT
42+
```
43+
44+
## Example
45+
46+
```csharp
47+
SELECT SQLNET::String_Occurrences4k('This is a String.', 's', 0)
48+
SELECT SQLNET::String_Occurrences4k('This is a String.', 's', 1)
49+
```

docs2/pages/documentations/string/string.md

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,4 +30,5 @@ Represents text as a sequence of UTF-16 code units.
3030
| [String_LastIndexOfInvariantCultureIgnoreCase(source, searchValue)](/string-last-indexof-invariant-culture-ignore-case) | Returns the zero-based index of the last occurrence of the specified string using culture-sensitive sort rules, the invariant culture, and ignoring the case of the strings. | [Try it]()|
3131
| [String_LastIndexOfOrdinal(source, searchValue)](/string-last-indexof-ordinal) | Returns the zero-based index of the last occurrence of the specified string using ordinal (binary) sort rules. | [Try it]()|
3232
| [String_LastIndexOfOrdinalIgnoreCase(source, searchValue)](/string-last-indexof-ordinal-ignore-case) | Returns the zero-based index of the last occurrence of the specified string using ordinal (binary) sort rules, and ignoring the case of the strings. | [Try it]()|
33-
| [String_Leangth(source)](/string-length) | Returns the number of characters in the specified string. | [Try it]()|
33+
| [String_Length(source)](/string-length) | Returns the number of characters in the specified string. | [Try it]()|
34+
| [String_Occurrences(source, searchValue, isCaseSensitive)](/string-occurrences) | Returns the number of occurrences in the specified string. | [Try it]()|

0 commit comments

Comments
 (0)