Solved

SSIS Derived column and regular expressions

Posted on 2010-09-20
3
1,753 Views
Last Modified: 2013-11-10
I have a data flow in SSIS similar to:

ID      CCODE
1        99024
2        71237
3        A4583
4        L8743

I have the following business rules:

•All codes that start with a “99” need to be first or “2” if there is no “99” code on the account.
•Next would be any codes that start with a “17” “12” “6” “2” “11”.
•Next would be the X-ray codes that start with a “7”.
•Then any codes that START with a letter, usually “A” “J” “L” “G” “Q” (HCPCS codes).

In order to sort, I was going to add a derived column in my data flow that added a new column and placed an order number in that column based on what it found in the CCODE column.

For example, I should get something like this:

ID      CCODE    DERIVEDORDER
1        99024            1
2        71237            3
3        A4583           4
4        L8743            4

Here is my derived column expression:

SUBSTRING(TransactionID,1,2) == "99" ? 1 : SUBSTRING(TransactionID,1,2) == "17" || SUBSTRING(TransactionID,1,2) == "12" || SUBSTRING(TransactionID,1,2) == "6%" || SUBSTRING(TransactionID,1,2) == "2%" || SUBSTRING(TransactionID,1,2) == "11" ? 2 : SUBSTRING(TransactionID,1,2) == "7%" ? 3 : SUBSTRING(TransactionID,1,2) == "[A-Z^]" ? 4 : 5

Everything works perfectly until I get to the last part - determining if CCODE starts with a letter.  That part does not work at all.  Specifically, the SUBSTRING(TransactionID,1,2) == "[A-Z^]" ? 4 : 5 part.

Is there a way using expressions in the derived column transform to determine if a string starts with letters?

JamesNT
0
Comment
Question by:JamesNT
[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
3 Comments
 
LVL 16

Accepted Solution

by:
vdr1620 earned 500 total points
ID: 33717435
the expression cannot evaluate the value to TRUE...You can try use Codepoint instead Like CODEPOINT(Column).. using that you can check if the starting value is Alphabet or Number..

Numbers from 0 to 9 have a codepoint of 48-57 ..So you can check that condition in the IF else expression
0
 

Author Comment

by:JamesNT
ID: 33721715
Working result:

SUBSTRING(TransactionID,1,2) == "99" ? 1 : SUBSTRING(TransactionID,1,2) == "17" || SUBSTRING(TransactionID,1,2) == "12" || SUBSTRING(TransactionID,1,2) == "6%" || SUBSTRING(TransactionID,1,2) == "2%" || SUBSTRING(TransactionID,1,2) == "11" ? 2 : SUBSTRING(TransactionID,1,2) == "7%" ? 3 : CODEPOINT(SUBSTRING(TransactionID,1,1)) < 48 || CODEPOINT(SUBSTRING(TransactionID,1,1)) > 57 ? 4 : CODEPOINT(SUBSTRING(TransactionID,LEN(TransactionID) - 1,1)) < 48 || CODEPOINT(SUBSTRING(TransactionID,LEN(TransactionID) - 1,1)) > 57 ? 5 : 6

Ugly, but functional.

For TransactionID:

All that start with 99 - Order = 1
All that start with 17, 12, 6, 2, 11 - Order = 2
All that start with 7 - Order = 3
All that start with a CODEPOINT <> 48 - 57 - Order = 4
All that end with a CODEPOINT <> 48 - 57 - Order = 5
All else - Order = 6

JamesNT
0
 

Author Closing Comment

by:JamesNT
ID: 33721716
THANKS!!!
0

Featured Post

Creating Instructional Tutorials  

For Any Use & On Any Platform

Contextual Guidance at the moment of need helps your employees/users adopt software o& achieve even the most complex tasks instantly. Boost knowledge retention, software adoption & employee engagement with easy solution.

Question has a verified solution.

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

Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
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…
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…
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties

695 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