August 10, 2011 at 12:55 pm
Hi,
I have a column that was designed to accept multiple email addresses (up to five email addresses) but I need to parse each address into it's own column for reporting. Below is any example of the column data:
Email Address
abc_corp@yahoo.com; abcCorp@abc.net; ABc-Corp@hotmail.com; jon.doe@abc.net ; jd-abcCorp@yahoo.com
What I want is five seperate email columns:
Email1 Email2 Email3 Email4 Email5
abc_corp@yahoo.com abcCorp@abc.net ABc-Corp@hotmail.com jon.doe@abc.net jd-abcCorp@yahoo.com
Thanks
MCTS: BI 2008, MCITP: BI 2008
Stay Thirsty My Friends
August 10, 2011 at 1:12 pm
use that to split.
http://www.sqlservercentral.com/articles/Tally+Table/72993/
Then use this technique to pivot (or just the native pivot in tsql).
Select columns, MAX(CASE WHEN RowId = 1 THEN Value ELSE NULL END) AS Email1, MAX(CASE WHEN RowId = 2 THEN Value ELSE NULL END) AS Email2....
FROM
GROUP BY Columns
August 14, 2011 at 6:23 pm
Ninja's_RGR'us (8/10/2011)
use that to split.http://www.sqlservercentral.com/articles/Tally+Table/72993/
Then use this technique to pivot (or just the native pivot in tsql).
Select columns, MAX(CASE WHEN RowId = 1 THEN Value ELSE NULL END) AS Email1, MAX(CASE WHEN RowId = 2 THEN Value ELSE NULL END) AS Email2....
FROM
GROUP BY Columns
Exactly what I needed and the reference was a good read - thanks for your help.
MCTS: BI 2008, MCITP: BI 2008
Stay Thirsty My Friends
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply