CHARINDEX() Function in SQL Server

Rumman Ansari   Software Engineer   2023-03-25   5537 Share
☰ Table of Contents

Table of Content:


Syntax:


CHARINDEX('Expression_To_Find', 'Expression_To_Search', 'Start_Location')

Returns the starting position of the specified expression in a character string. Start_Location parameter is optional. In this example, we get the starting position of '@' character in the email string 'sara@aaa.com'.

Code:


Select CHARINDEX('@','sara@aaa.com',1)


Output:

The above code will produce the following result-


 5