sql server - Using Expressions to determine if string starts with a letter -


i need building condition statement within ssis expression allow me filter out 9 position varchar field must start 2 alphabetic characters.

pattern should follow: aa0000000

my goal have data flow hit conditional split , dump illegal records out dump file later qa.

example:

  • aq1234567 <-- legal
  • pa9876543 <-- legal
  • rr1133456 <-- legal
  • k12345g65 <-- illegal
  • 098874312 <-- illegal

i open other methods have handling filter. data coming excel document start , unfortunately there no prevalidation of data prior hitting load process.

restricting solution expression space, tool you're looking codepoint. returns integer value of first character finds. armed handy dandy ascii table, need call codepoint on first , second characters in source column , test values between character range a-z.

this tests first character codepoint(src) , test second character codepoint(substring(src,2,1))

putting logic results in ugly expression

(codepoint(substring(src,2,1)) >= 65      && codepoint(substring(src,2,1)) < 91)  && (codepoint(src) >= 65      && codepoint(src) < 91) ? true : false 

enter image description here

my rule of thumb when expressions scroll way off screen, prefer drop logic script component. or break multiple derived column components makes maintenance easier.


Comments

Popular posts from this blog

c++ - CryptStringToBinary API behavior -

c++ - Correct method for redrawing a layered window -

java.util.scanner - How to read and add only numbers to array from a text file -