Solved

SQL String with DTS, using split string

Posted on 2014-01-08
6
450 Views
Last Modified: 2014-01-09
I have a derived Column transformation in my DTS package that gets a Job number using an expression:

SUBSTRING(@[User::CurrentExcelPath],51,12) where (@[User::CurrentExcelPath] contains the filepath.

My job numbers have changed where length will not work.

I need to change to a split string.
My End goal is to strip out the job numbers from a given path. The below is 2 examples of a path

Example #1
W:\ProcessFiles\Labor_Sheet_Importation_123\ JOBNO_2014-01-01014_11331_URI- Daily Labor-Culpepper Recon 1-2-14.xlsm
Example #2
W:\ProcessFiles\Labor_Sheet_Importation_123\ JOBNO_2014-01-0001-RECON_11331_URI- Daily Labor-Culpepper Recon 1-3-14.xlsm

end result for Job Number will be:

"2014-01-0104"
"2014-01-0001-RECON"


How can I change this to strip out the job Number using a split string and will
derived column transformation Expression accept a split string?

The number of  underscores will always be the same, 3, but the lenght may vary from 12 to 18 now.
0
Comment
Question by:BKennedy2008
[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
  • 4
6 Comments
 

Author Comment

by:BKennedy2008
ID: 39766051
It appears I cannot use a derived column to pull this out, I guess I would need a script to pull this out in my data flow
0
 
LVL 34

Accepted Solution

by:
Brian Crowe earned 250 total points
ID: 39766073
try using CHARINDEX

SELECT SUBSTRING(@filepath, CHARINDEX('JOBNO', @filepath) + 6,
      CHARINDEX('_', @filepath, CHARINDEX('JOBNO', @filepath) + 6) - CHARINDEX('JOBNO', @filepath) - 6)

replace @filepath with @[User::CurrentExcelPath]
0
 

Author Comment

by:BKennedy2008
ID: 39766098
Am I going to use the above in a script component? Such as the image in my data flow below?
 Data flow
0
Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

 
LVL 41

Assisted Solution

by:Sharath
Sharath earned 250 total points
ID: 39766113
If you are looking for SQL solution, you can try this.Dump all raw data from CurrentExcelPath into a variable in a stage table and you can extract the needed string.
		 
select parsename(replace(replace(reverse(substring(reverse(JobName),1,charindex('\',reverse(JobName))-1)),'.',':'),'_','.'),3) JobName
  from test

Open in new window

http://sqlfiddle.com/#!3/20320/11
0
 

Author Comment

by:BKennedy2008
ID: 39766149
I think the script component is the path I would like to take, just need to figure out how to assign the input and output of the variables, the input being the @[User::CurrentExcelPath]
0
 

Author Closing Comment

by:BKennedy2008
ID: 39769361
Thanks for the help. I used a Script Component and used split function and set a variable to the JobNO Part. More coding than I wanted, but got the trick done.
0

Featured Post

Best Practices: Disaster Recovery Testing

Besides backup, any IT division should have a disaster recovery plan. You will find a few tips below relating to the development of such a plan and to what issues one should pay special attention in the course of backup planning.

Question has a verified solution.

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

In this article we will get to know that how can we recover deleted data if it happens accidently. We really can recover deleted rows if we know the time when data is deleted by using the transaction log.
I have a large data set and a SSIS package. How can I load this file in multi threading?
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
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.

737 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