Showing posts with label digits. Show all posts
Showing posts with label digits. Show all posts

Monday, March 19, 2012

Conditional split questions

I have a zipcode column that contains xxxxx-xxxx, i want to use conditional split so that i can take the last 4 digits and put them into a different column, I tried to use the SUBSTRING ("ZIP", 6, 4) but it returns an error, any ideas on how i can split it?

Thanks.

Actually, I think you want the derived column transform, not the conditional split. Your SUBSTRING should work fine.|||

I think you want a Derived Column Transfomation too, but you have a couple of mistakes, assuming this is a SSIS expression-

You need to remember the SSIS expression syntax is C style and therefore zero based, so index 7 is the start of the last section, I assume you are skipping the hyphen.

You have used double quotes, this makes it a literal.

Try SUBSTRING(Zip, 7, 4)

Both points don't count if you are still trying to do this on SQL, but I assume you wanted a SSIS solution.

As a rule it helps a lot if you give the details of the error, things like error message, as save a lot of guess work when trying to help you.

Sunday, March 11, 2012

Conditional Split Question

Hello,

I am have an ID column that sometimes contains all numeric characters and sometimes contains all digits. I would like to the records with all digits (0-9) to continue downstream in my Data Flow. I would like the records that contain characters other than digits to be logged to a table.

This sounds like a job for the Conditional Split transformation, but I don't see a way to easily test for a numeric value. For example, I would like to use something like ISNUMERIC([MyIDField]) for testing the values in my Conditional Split, but I don't see a way to do this.

Do I have to create a Derived Column transformation prior to my conditional split that populates a "numeric" ID column for each of my records then test this Derived Column in my Conditional Split? Seems like more work than I would to see for something as simple as testing for a numeric...

TIA...

Brian

"numeric characters and sometimes contains all digits"... digits are numeric? Anyway I'd use my Regular Expression Transform http://www.sqlis.com/default.aspx?91. It will handle the test and split, and regular expressions are great for validating things like this.

|||

Brian,

You are correct, there is no ISNUMERIC() function in the expression evaluator. However, in your case, there is a fairly decent workaround I think.

If you are SURE that the string is never a mix of numeric and character data, you could use the following expression to direct alpha strings (where Col is the name of your input column:

FINDSTRING("0123456789", SUBSTRING(Col, 1, 1), 1) == 0

This expresssion will be true if the first character of Col is an alpha character.

Hope this helps.

Mark