Mastering the CHARINDEX() Function in SQL Server: A Detailed Guide

Rumman Ansari   Software Engineer   2024-07-21 09:36:22   5525  Share
Subject Syllabus DetailsSubject Details
☰ TContent
☰Fullscreen

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