SQL Flow Field Guide

CHARINDEX

Catalog support for SQL Server 2022 (16.x) and 2025 (17.x)

string transform

What changes

Input
string arguments
Output or change
string or integer
Return type
bigint if expressionToSearch has an nvarchar(max), varbinary(max), or varchar(max) data type; int otherwise.

Syntax at a glance

CHARINDEX ( expressionToFind , expressionToSearch [ , start_location ] )

Work example

Find the position of a delimiter before parsing a string.

Handle a zero result before passing the position to a later substring operation.

Check your work CHARINDEX returns zero when the search text is absent and uses the input collation for comparison.

Practice SQL

Open in SQL Flow
SELECT CHARINDEX('-', 'INV-2048') AS delimiter_position;

Open Microsoft Learn for full syntax, permissions, and details for your version.