Search This Blog

Wednesday, July 25, 2012

CHARINDEX (SQL Server)

SQL Server > Built-in Functions > CHARINDEX

CHARINDEX SQL Server function searches an expression for another expression and returns its starting position if found.

Example

declare @t nvarchar(max)
set @t = 'blue; red; green'

SELECT CHARINDEX(';', @t);

Result
(No column name)

5

SELECT CHARINDEX(':', @t);
Result
(No column name)
0