CHARINDEX()
Transact-SQL reference for the CHARINDEX function.
Signature
CHARINDEX ( expressionToFind , expressionToSearch [ , start_location ] )Parameters
- expressionToFind — A character expression containing the sequence to find. *expressionToFind* has an 8,000 character limit.
- expressionToSearch — A character expression to search.
- start_location — An integer or bigint expression at which the search starts. If *start_location* isn't specified, has a negative value, or has a zero (`0`) value, the search starts at the beginning of *expressionToSearch*.
Examples
SELECT CHARINDEX('board', 'keyboard') AS position;position
-----------
4SELECT CHARINDEX('is', 'This is a string');3SELECT CHARINDEX('is', 'This is a string', 4);6Run against SQL Server 16.0.4265.3 on 2026-09-13. This is the output we got, not the documentation’s.
Available on
- SQL Server 2017 and later
- Azure SQL Database
- Azure SQL Managed Instance
- Azure Synapse Analytics
- Analytics Platform System (PDW)
- Microsoft Fabric warehouse
- Fabric SQL database
Signature and description adapted from the Microsoft SQL documentation, used under the CC BY 4.0. SQL Server and Azure are trademarks of the Microsoft group of companies. This page is not affiliated with Microsoft.