Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
Author |
Topic |
Andre1802
Starting Member
4 Posts |
Posted - 2014-11-19 : 07:26:54
|
HiI ma struggling getting the following case statement into the derived column formatCASE WHEN SUBSTRING(REPLICATE('0', 9 - LEN(Data)) + CAST(CYCLE_YYYYMM AS VARCHAR(9)), 4, 6) IS NULLTHEN 0ELSE RTRIM(SUBSTRING(REPLICATE('0', 9 - LEN(Data)) + CAST(Data AS VARCHAR(9)), 4, 6))ENDCan anyone help please |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-11-19 : 09:14:20
|
what are you getting with this case expression (it's not a statement) and what do you want to get? Please post examples. |
|
|
Andre1802
Starting Member
4 Posts |
Posted - 2014-11-20 : 05:07:45
|
Please note I need the derived column script syntax for SSISSorry here is the corrected codeCASE WHEN SUBSTRING(REPLICATE('0', 9 - LEN(Data)) + CAST(Data AS VARCHAR(9)), 4, 6) IS NULLTHEN 0ELSE RTRIM(SUBSTRING(REPLICATE('0', 9 - LEN(Data)) + CAST(Data AS VARCHAR(9)), 4, 6))ENDHere are two examples for the data in Datarow 1 - 1201303row 2 - 123456789row 3 - nullrow 4 - 12345678the first row result would be 201303row 2 result would be 456789row 3 result would be 0row 4 result would be 345678 |
|
|
|
|
|