Solved

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

Posted on 2013-05-20
4
355 Views
Last Modified: 2016-02-10
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.
0
Comment
Question by:Steven Reid
  • 2
4 Comments
 
LVL 10

Expert Comment

by:HuaMinChen
Comment Utility
Use
..
case when charindex('J',[entity Id])>0 then 'Y' else 'N' end as Joint_account
from table1
...
0
 
LVL 48

Accepted Solution

by:
PortletPaul earned 500 total points
Comment Utility
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
 

Author Comment

by:Steven Reid
Comment Utility
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
 
LVL 48

Expert Comment

by:PortletPaul
Comment Utility
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

Featured Post

Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

Join & Write a Comment

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
My client sends a request to me that they want me to load data, which will be returned by Web Service APIs, and do some transformation before importing to database. In this article, I will provide an approach to load data with Web Service Task and X…
Viewers will learn how the fundamental information of how to create a table.
Viewers will learn how to use the SELECT statement in SQL and will be exposed to the many uses the SELECT statement has.

762 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now