Solved

SQL String with DTS, using split string

Posted on 2014-01-08
6
453 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
Transaction Monitoring Vs. Real User Monitoring

Synthetic Transaction Monitoring Vs. Real User Monitoring: When To Use Each Approach? In this article, we will discuss two major monitoring approaches: Synthetic Transaction and Real User Monitoring.

 
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

What Is Transaction Monitoring and who needs it?

Synthetic Transaction Monitoring that you need for the day to day, which ensures your business website keeps running optimally, and that there is no downtime to impact your customer experience.

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.
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function

719 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