I have strings in a database like this:
[email protected]
And I only need the characters that appear before the @ symbol.
I am trying to find a simple way to do this in SQL.
I have strings in a database like this:
[email protected]
And I only need the characters that appear before the @ symbol.
I am trying to find a simple way to do this in SQL.
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.