How to trim laeding zeroes in numeric filed
How do I trim leading zeroes from a numeric field in my fklat file before loading to SQL table?
March 14th, 2011 9:05am
u can do this using derived column
Ltrim(Replace([ColumnName], '0', ' '))
Free Windows Admin Tool Kit Click here and download it now
March 14th, 2011 9:11am
I thought Ltrim was for string fields? My field is numeric, precision 7, scale 2.
March 14th, 2011 9:14am
so cast it as a string:
Ltrim(Replace(CAST([ColumnName] as varchar(10)), '0', ' '))
-Tab Alleman
Free Windows Admin Tool Kit Click here and download it now
March 14th, 2011 9:20am
Careful!
The answer above is not yielding the correct result. E.g. when string 002002 used even the internal 0s
get removed/replaced !
In the derived column you need to use the SSIS Expressions, not SQL.
An expression like following is likely needed because since you have leading zeros the variable is of type string, not numeric:
(DT_WSTR,10)(DT_I4)[StringVar]
There you convert to to int and then back to string, thus effectively removing the leading 0s.
Arthur My Blog
March 14th, 2011 9:46am
A data conversion component can be used.Nitesh Rai- Please mark the post as answered if it answers your question
Free Windows Admin Tool Kit Click here and download it now
March 14th, 2011 9:51am
But it is defined as numeric in my Mainframe program. PIC 9 (5) V99.
March 14th, 2011 10:00am
But once it hits the flat file it becomes "text".Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
March 14th, 2011 10:01am
So the expression would be (DT_WSTR, 7)(DT_NUMERIC)[ColumnName] ?
March 14th, 2011 10:05am
How did you define your column in the Flat File Source?Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
March 14th, 2011 10:13am
numeric, precision 7, scale 2.
March 14th, 2011 10:19am
And you get 0s when you see the data?Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
March 14th, 2011 10:35am
Every record goes to my Data Convert Error file with: -1071607673,270
270 is supposed to be the column but my files records are only 200 bytes so I don't know why it is saying column 270?
March 14th, 2011 10:38am
Can you capture a screenshot of this and publish it here (for how to see the general forum notes)?Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
March 14th, 2011 10:48am
A screenshot of ?
March 14th, 2011 10:59am
Enable data viewers to see what do you get at every stage. Capture screen-shots.
Why don't you declare this column as string?Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
March 14th, 2011 11:08am
Should I have my codepage in the connection manager editor sset to 1140 (IBM EBCDIC - US) instead of the default 1252 (ANSI - Latin I) ?
March 14th, 2011 11:08am
I started to recall another topic by you. I told you there that mainframe machines typically produce EBCDIC formatted files.
You need to know in what encoding and format you are getting the source file. If in EBCDIC, then you need to convert to ASCII before anything.Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
March 14th, 2011 11:16am
Ok, I have confirmed the source is in ASCII format, so what codepage do I chhose in the connection manager?
March 14th, 2011 12:48pm
Use the default code page.Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
March 14th, 2011 1:13pm
Please note: that the asking for help person posted into a new thread at http://social.msdn.microsoft.com/Forums/en-US/sqlintegrationservices/thread/bdd56e41-e0cb-4d7f-9f4c-1255cdda6377Arthur My Blog
March 14th, 2011 2:15pm