Length func expression in ssis derived column
-
Sunday, April 01, 2012 12:24 AM
Hi All,
Can anybody tell me the mistake in this derived column expression..here amount data type is varchar(8).
I want to display amount as 00091900 if I get 91900
((LEN([Amount])==1?"0000000"+[Amount]:[Amount]):(LEN([Amount])==2?"000000"+ [Amount]: [Amount]))
Thanks,
RH
sql
All Replies
-
Sunday, April 01, 2012 12:36 AM
I am going to assume that Amount is varchar(8)
Try the following expression:
RIGHT("00000000" + [Amount] , 8 )Russel Loski, MCT, MCITP Business Intelligence Developer and Database Developer 2008
- Proposed As Answer by SSISJoostMicrosoft Community Contributor, Moderator Sunday, April 01, 2012 5:25 PM
- Marked As Answer by Challen FuModerator Sunday, April 22, 2012 10:07 AM
-
Sunday, April 01, 2012 2:22 PM
Hello,
Below links will help you.
http://sqlage.blogspot.in/2011/03/remove-leadingtrailing-or-both-zeros-in.html
http://stackoverflow.com/questions/9614897/removing-leading-zeros-in-ssis
http://stackoverflow.com/questions/9614897/removing-leading-zeros-in-ssis- Edited by willsonyano Sunday, April 01, 2012 2:22 PM
-
Sunday, April 01, 2012 5:27 PMModerator
Two possible expressions for leading zeros:
- RIGHT(("00000000" + [STRING_COLUMN]), 8)
- REPLICATE("0", 8 - LEN([STRING_COLUMN])) + [STRING_COLUMN]
Please mark the post as answered if it answers your question | My SSIS Blog: http://microsoft-ssis.blogspot.com | Twitter
- Edited by SSISJoostMicrosoft Community Contributor, Moderator Sunday, April 01, 2012 5:30 PM
- Proposed As Answer by Jerry NeeModerator Thursday, April 05, 2012 6:02 AM
- Marked As Answer by Challen FuModerator Sunday, April 22, 2012 10:07 AM

