[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

SSIS Derived column and regular expressions

Posted on 2010-09-20
3
Medium Priority
?
1,808 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 2000 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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
In this article we will learn how to fix  “Cannot install SQL Server 2014 Service Pack 2: Unable to install windows installer msi file” error ?
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

649 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