CHARINDEX (Transact-SQL) : Syntax Arguments
CHARINDEX (Transact-SQL) : Syntax Arguments
07/24/2017
3 minutes to read
o
o
o
o
o
o +6
APPLIES TO: SQL Server Azure SQL Database Azure Synapse Analytics
(SQL DW) Parallel Data Warehouse
This function searches for one character expression inside a second character
expression, returning the starting position of the first expression if found.
Syntax
SQLCopy
CHARINDEX ( expressionToFind , expressionToSearch [ , start_location ] )
Arguments
expressionToFind
A character expression containing the sequence to find. expressionToFind has an
8000 character limit.
expressionToSearch
A character expression to search.
start_location
An integer or bigint expression at which the search starts. If start_location is not
specified, has a negative value, or has a zero (0) value, the search starts at the
beginning of expressionToSearch.
Return types
bigint if expressionToSearch has an nvarchar(max), varbinary(max),
or varchar(max) data type; int otherwise.
Remarks
If either the expressionToFind or expressionToSearch expression has a Unicode data
type (nchar or nvarchar), and the other expression does not, the CHARINDEX
function converts that other expression to a Unicode data type. CHARINDEX cannot
be used with image, ntext, or text data types.