0

I have strings in a database like this:

firstname.lastname@domain.com

And I only need the characters that appear before the @ symbol.

I am trying to find a simple way to do this in SQL.

6

If you need to get the value before the @ character, you'll need to use something like:

SELECT LEFT(Email, CHARINDEX('@',Email)-1) FIELD_ALIAS FROM YOUR_DE

Replace the FIELD_ALIAS with the name of the field where you want to store this value. Also, replace Email with the field from where you'll be getting the emails..

Basically, we are using the LEFT and CHARINDEX functions of SQL Server.

CHARINDEX('@',Email) will return the index of the @ character. And since we don't want to get this character, we need to substract 1 from it.

LEFT will return all characters to the left of the @ character.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.