bugl
bugl
HomeLearnPatternsPathsSearch
HomeLearnPatternsPathsSearch

Loading lesson path

Learn/SQL/SQL References
SQL•SQL References

SQL Server CHARINDEX() Function

Flash cards

Review the key moves

1/4
Core idea

What is the main idea behind SQL Server CHARINDEX() Function?

Lesson checks

Practice each idea before moving on

Short Mimo-style checks built from this lesson's code, terms, and sequence.

1Quick choice

Which statement best captures the main point of this lesson?

2Fill blank

Complete the missing token from the example code.

___('t', 'Customer') AS MatchPosition;
3Order

Put the learning moves in the order that makes the concept easiest to apply.

The CHARINDEX() function searches for a substring in a string, and returns the position.
Definition and Usage
SQL Server CHARINDEX() Function

Example

SELECT
CHARINDEX('t', 'Customer') AS MatchPosition;

Definition and Usage

The CHARINDEX() function searches for a substring in a string, and returns the position.

If the substring is not found, this function returns 0.

Note

This function performs a case-insensitive search.

Syntax

CHARINDEX(
substring
,
 string
,
start
)

Parameter Values

ParameterDescription
substringRequired. The substring to search for
stringRequired. The string to be searched
startOptional. The position where the search will start (if you do not want to start at the beginning of s tring ). The first position in string is 1

Technical Details

Works in:SQL Server (starting with 2008), Azure SQL Database, Azure SQL Data Warehouse, Parallel Data Warehouse

Previous

SQL Server CHAR() Function

Next

SQL Server CONCAT() Function