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.
Salesforce Stack Exchange is a question and answer site for Salesforce administrators, implementation experts, developers and anybody in-between. It only takes a minute to sign up.
Sign up to join this communityIf 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.