0 votes
1 view
in SQL by (22.4k 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 (40.3k points)

Use CHARINDEX in your code like this: 

select CHARINDEX('@', '[email protected]')

-----------

8(1 row(s) affected)

Or else use below code:

select CHARINDEX('c', 'abcde')

-----------

3 (1 row(s) affected)

Related questions

0 votes
1 answer
+2 votes
1 answer
0 votes
1 answer
asked Jul 23, 2019 in SQL by Tech4ever (22.4k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...