Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

SSIS derived column remove text from string, keep only numeric values

I am trying to remove text from a specific column and only keep the numeric values. I tried to use a derived column and also tried to search for the answer, but did not find the solution.

For example, the table looks like this:

order_number
1001
1002 k
1003
text
1004
aa 1007

I hope somebody could help me with this. Thanks in advance

This is the error I get:

screenshot error

like image 626
user7418776 Avatar asked Apr 13 '26 02:04

user7418776


1 Answers

You could use a script component (make sure to add an output column (outordernumber)):

if(!Row.ordernumber_IsNull){
    Row.outordernumber = System.Text.RegularExpressions.Regex.Replace(Row.ordernumber, "[^0-9]", "")
}else{
    Row.outordernumber_IsNull = true;
}   

I think you missed this step:

enter image description here

Package Result:

enter image description here

like image 165
KeithL Avatar answered Apr 16 '26 11:04

KeithL



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!