Solved

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

Posted on 2013-05-20
4
363 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 11

Expert Comment

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

Accepted Solution

by:
PortletPaul earned 500 total points
ID: 39183260
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
ID: 39186208
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 49

Expert Comment

by:PortletPaul
ID: 39186228
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

Edgartown IT Case Study

Learn about Edgartown's quest to ensure the safety and security of the entire town's employee and citizen data. Read the case study!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
This video shows how to set up a shell script to accept a positional parameter when called, pass that to a SQL script, accept the output from the statement back and then manipulate it in the Shell.
Via a live example, show how to shrink a transaction log file down to a reasonable size.

696 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