You have an SSIS Variable with a data type of int. The desire is to do string-like concatenation to append month data to it.
The cheap route is to cast your integer to string, concatenate your values and then cast back to a numeric data type. Don't do that. Your opportunity for error handling is less than stellar with the SSIS expression language plus it's horribly inefficient.
The better route is to use math. You have 2013
You'd like to get to 2013001...2013012
Mathematically add enough zeros to the end of 2013 until your months fit and then do regular addition. 2013 * 1000 + 1 ... 2013 * 1000 + 12
A Query would look like
SELECT
BASE.year_number + MONTHS.month_number
FROM
(
SELECT 2013 * 1000
) BASE (year_number)
CROSS JOIN
(
SELECT TOP 12
ROW_NUMBER() OVER (ORDER BY (SELECT NULL)) AS n
FROM
information_schema.COLUMNS ISC
) MONTHS(month_number);
In SSIS, the same concept will apply. Add a derived column, call it YearBase
and for the value, it will be @[User::MyYearVariable] * 1000
. Now the downstream components will be able to access the column "YearBase."
Option 1
Use Multicast is to split it 12 times and add a Dervied column to that output. In those Derived Columns, create another column, ComputedYearMonth
type of int32 and then set your formula to be [YearBase] + 1
... [YearBase] + 12
.
Option 2
I'm lazy. I assume that after the derived column stuff in option 1, you're probably going to bring all those rows back together with a union all. You can do that, but that's about 16 more boxes on a data flow than I'd care to maintain. Never reach for the script component as your first tool of choice but for a situation like this, I'd probably use it. Drag a Script Component
onto your canvas and configure it to operate in Asynchronous mode and then push the above logic into the script.