October 25, 2018 at 10:24 am
Hello
HOw can I separate this data
I have buch of emails in a row, I need to keep just one and remove the rest
example:
"angelina.uhi@ors.org oladi.ade@ors.org"
Result should be just 1 email:
Thank you
October 25, 2018 at 10:42 am
Krasavita - Thursday, October 25, 2018 10:24 AMHelloHOw can I separate this data
I have buch of emails in a row, I need to keep just one and remove the rest
example:angelina.uhi@ors.org oladi.ade@ors.org
Result should be just 1 email:
Thank you
SELECT LEFT(emailColumn,CHARINDEX(' ',emailColumn)-1)
FROM myTable
October 25, 2018 at 10:57 am
there is also there at the beginning and end email ", after this code they were removed but how to remove on left side.
Thank you
October 25, 2018 at 11:23 am
Krasavita - Thursday, October 25, 2018 10:57 AMthere is also there at the beginning and end email ", after this code they were removed but how to remove on left side.Thank you
Really? Ever hear of REPLACE?
October 25, 2018 at 11:33 am
it is not working for me and I am asking for help
(LEFT([Person Email],(CHARINDEX(' ',[Person Email])-1),REPLACE([Person Name] , '"', ''))
October 25, 2018 at 12:05 pm
Krasavita - Thursday, October 25, 2018 11:33 AMit is not working for me and I am asking for help(LEFT([Person Email],(CHARINDEX(' ',[Person Email])-1),REPLACE([Person Name] , '"', ''))
This?
declare @TestString varchar(64) = '"angelina.uhi@ors.org oladi.ade@ors.org"';
select
@TestString
, left(@TestString,charindex(' ',@TestString))
, replace(left(@TestString,charindex(' ',@TestString)),'"','');
go
October 29, 2018 at 11:52 am
Hello
Thank you so much:
so it works for this:
"bassam.nasser@crs.org julia.leis@crs.org"
t doesn't work for this:
bass.nasr@rs.org julia.liii@rs.org
Can you please help?
October 29, 2018 at 11:59 am
Krasavita - Monday, October 29, 2018 11:52 AMHelloThank you so much:
so it works for this:
"bassam.nasser@crs.org julia.leis@crs.org"
t doesn't work for this:bass.nasr@rs.org julia.liii@rs.org
Can you please help?
What do you mean it doesn't work? You do realize we can't see what you see and you didn't post anything to work with so anything we given, if tested, is tested based on what we know not what you are dealing with.
You have been here long enough to know that to get good answers you need to post DDL, sample data, and expected results.
October 29, 2018 at 12:06 pm
And FYI, my testing code seems to work just fine:
declare @TestString varchar(64) = '"angelina.uhi@ors.org oladi.ade@ors.org"';
select
@TestString
, left(@TestString,charindex(' ',@TestString))
, replace(left(@TestString,charindex(' ',@TestString)),'"','');
go
declare @TestString varchar(64) = 'angelina.uhi@ors.org oladi.ade@ors.org';
select
@TestString
, left(@TestString,charindex(' ',@TestString))
, replace(left(@TestString,charindex(' ',@TestString)),'"','');
go
October 29, 2018 at 9:06 pm
Krasavita - Thursday, October 25, 2018 10:24 AMHelloHOw can I separate this data
I have buch of emails in a row, I need to keep just one and remove the rest
example:"angelina.uhi@ors.org oladi.ade@ors.org"
Result should be just 1 email:
Thank you
It would appear that you only want the first email address regardless of how many email addresses there may be. If that is correct, the following will work.
--===== Create and populate a test table.
-- This is not a part of the solution.
CREATE TABLE #TestTable (TestString VARCHAR(64))
;
INSERT INTO #TestTable
(TestString)
VALUES ('"angelina.uhi@ors.org oladi.ade@ors.org"')
,('bass.nasr@rs.org julia.liii@rs.org')
,('ladi.ade@ors.org bass.nasr@rs.org julia.liii@rs.org')
,('"homer.simpson@hs.org"')
;
--===== Solve the given problem
SELECT TestString --just for verification
,CleanString = REPLACE(SUBSTRING(TestString,1,ISNULL(NULLIF(CHARINDEX(' ',TestString),0),64)),'"','')
FROM #TestTable
;
--Jeff Moden
Change is inevitable... Change for the better is not.
October 30, 2018 at 7:09 am
I found problem in email it goes like that:'%@rs.org
%'
eamplee:
( N'ba@rs.org
julia.leis@rs.org' )
think split needs to be used by not sure i
how can this be separated for only one email? example end result should be:ba@rs.org
thank you so much
October 30, 2018 at 8:16 am
Krasavita - Tuesday, October 30, 2018 7:09 AMI found problem in email it goes like that:'%@rs.org
%'
eamplee:
( N'ba@rs.org
julia.leis@rs.org' )how can this be separated for only one email? example end result should be:ba@rs.org
thank you so much
Are you saying the data appears on two separate lines as you have it above?
Also, you said nothing about this being NVARCHAR in your original post. What are your language settings for the database?
--Jeff Moden
Change is inevitable... Change for the better is not.
October 30, 2018 at 8:18 am
If you want to stop going back and forth with incremental questions, please take the time to post the code to create a table and populate it as I did in my example. It'll also help a whole lot with the language barrier.
--Jeff Moden
Change is inevitable... Change for the better is not.
October 30, 2018 at 8:28 am
WHEN a.[Person Email] LIKE '%.uF%' THEN REPLACE(REPLACE([Person Email] , '.uF', ''), '', '')
WHEN a.[Person Email] LIKE '%@xs.org%' THEN REPLACE([Person Email] , '@xs.org', '@rs.org')
ELSE
a.[Person Email]
END AS [Person Email],
a.[Person Email] AS [Person Email_old]
October 30, 2018 at 8:36 am
Thanks for your code but can you please do as I asked and provide the sample data in a readily consumable format as I did in my example? If you don't understand what I did, please read the article at the first link in my signature line below. Thanks.
--Jeff Moden
Change is inevitable... Change for the better is not.
Viewing 15 posts - 1 through 15 (of 42 total)
You must be logged in to reply to this topic. Login to reply