how to get index of in sql server?

I have an field with name email like "abcd@abc.com"

I want to get first text of @ which is "abcd" and set it into another field username.

By  Adil Shahbaz    11-Sep-2023    2

Solutions


Nawab

You get this by using LEFT and CHARINDEX

 

SELECT LEFT('abcd@abc.com, CHARINDEX('@', 'abcd@abc.com') - 1) AS username

Your Answer

10033