there were two thread in this week which has issue when compare two strings in SSIS Expressions,
for example request was "9:9" < "99" .
if you try the above expression in SSIS, you will get True as result.
this may seems OK, but requests was to compare them by ASCII character, if you look at ASCII table, you will find that ascii("9") is 57, but ascii(":") is 58 . This means that if you compare these two string in ascii order, result should be "9:9" is greater than "99".
So there are two questions:
1- what sort order is used in string comparison in SSIS expressions?
2- how you can compare two string based on ASCII order?
1- when you compare two string in SSIS expression, this will compare them by String SORT method. and this will sort nonalphanumerical characters first, and then alphanumerical characters. in this sorting option ":" comes before "9". so if your compare "9:9" with "99", result is : "9:9" is lower than "99" .
this is MSDN evidence:
2- for compare two string based on ASCII codes, use Ordinal compare option.
Ordinal Compare Option as MSDN defined:
Indicates that the string comparison must use successive Unicode
UTF-16 encoded values of the string (code unit by code unitcomparison),
leading to a fast comparison but one that is culture-insensitive. A
string starting with a code unit XXXX16 comes before a string starting with YYYY16, if XXXX16 is less than YYYY16. This value cannot be combined with other values and must be used alone.
so if you write this .NET code:
string.Compare("9:9", "99", new
this will result 1, means that "9:9" is greater than "99".
Note that you should write this code in Script component to compare strings by ascii order.
for more information about other compare options of string.compare method look here .