0 votes
1 view
in SQL by (16.3k points)

Given an email address column, I need to find the position of the @ sign for the substring.

What is the index of function, for strings in T-SQL?

Looking for something that returns the position of a substring within a string.

in C#

var s = "abcde";

s.IndexOf('c'); // yields 2

1 Answer

0 votes
by (34.9k points)

Use CHARINDEX in your code like this: 

select CHARINDEX('@', 'someone@somewhere.com')


8(1 row(s) affected)

Or else use below code:

select CHARINDEX('c', 'abcde')


3 (1 row(s) affected)