Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

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

Posted on 2013-05-20
4
Medium Priority
?
366 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 2000 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

Concerto's Cloud Advisory Services

Want to avoid the missteps to gaining all the benefits of the cloud? Learn more about the different assessment options from our Cloud Advisory team.

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
In part one, we reviewed the prerequisites required for installing SQL Server vNext. In this part we will explore how to install Microsoft's SQL Server on Ubuntu 16.04.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

604 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