Help creating derived column in SSIS to remove trailing character and set column based on value

Hi,

I have a CSV file which has a column that shows the Entity_ID for our CRM system, in the following format

"Entity Id","Entity Name"
"57468","The ABC Superannuation Fund"
"57468","The ABC Superannuation Fund"
"66180J","Fred & Wilma Flinstone (Joint)"
"66180J","Fred & Wilma Flinstone (Joint)"
"87866","Rubble Super Fund"
"87866","Rubble Super Fund"

What I need to do is create  two new columns based on the Entity ID column showing the numeric ID code and a column to indicate that it is a joint account.

Entity Id      Entity Name                                       Raw_EntityID     Joint_Account
57468      The ABC Superannuation Fund              57468                  N
57468      The ABC Superannuation Fund              57468                  N
66180J     Fred & Wilma Flinstone (Joint)                66180                  Y
66180J     Fred & Wilma Flinstone (Joint)                66180                  Y
87866      Rubble Super Fund                                  87866                  N
87866      Rubble Super Fund                                  87866                  N


Any ideas very much appreciated.
Steven ReidHead of Process ImprovementAsked:
Who is Participating?
 
PortletPaulConnect With a Mentor freelancerCommented:
and adding strip 'J' from entity

...
, replace([entity Id],'J','') as Raw_EntityID
, case when charindex('J',[entity Id])>0 then 'Y' else 'N' end as Joint_account
from table1
0
 
HuaMin ChenSystem AnalystCommented:
Use
..
case when charindex('J',[entity Id])>0 then 'Y' else 'N' end as Joint_account
from table1
...
0
 
Steven ReidHead of Process ImprovementAuthor Commented:
Thanks Portlet Paul.
So you think that a new SQL task with this as an update or insert, is a better way compared to a Derived column?
0
 
PortletPaulfreelancerCommented:
That would depend on may factors.

If you need Raw_EntityID & Joint_Account in many situations it might be more efficient to have those values stored instead of derived. Using an update is one approach.
OR
you could possibly add these as 'computed columns' to the table perhaps, and in this option you can have it 'persisted' as well
OR
create View that produces these derived columns that you can re-use instead of having to repeat the string manipulation code in query code.

The point is there are options but I don't know which suits you best.
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.