?
Solved

SQL String with DTS, using split string

Posted on 2014-01-08
6
Medium Priority
?
459 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 1000 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
VIDEO: THE CONCERTO CLOUD FOR HEALTHCARE

Modern healthcare requires a modern cloud. View this brief video to understand how the Concerto Cloud for Healthcare can help your organization.

 
LVL 41

Assisted Solution

by:Sharath
Sharath earned 1000 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

Moving data to the cloud? Find out if you’re ready

Before moving to the cloud, it is important to carefully define your db needs, plan for the migration & understand prod. environment. This wp explains how to define what you need from a cloud provider, plan for the migration & what putting a cloud solution into practice entails.

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…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
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…
Familiarize people with the process of retrieving data from SQL Server using an Access pass-thru query. Microsoft Access is a very powerful client/server development tool. One of the ways that you can retrieve data from a SQL Server is by using a pa…

764 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