September 5, 2012 at 4:38 pm
Hi ,
I am going to store the date value data'30\04\2012' coming from csv into sql table column like'201204'.
Please help me how to set the expression of SSIS derived column ?
Regards,
Kumar
September 6, 2012 at 2:39 am
Any help??????????????
Regards,
Kumar
September 6, 2012 at 3:03 am
Use the SUBSTRING() function.
Have a try and post back with how you get on.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
September 6, 2012 at 3:14 am
I need data like 201204 and storing into int datatype.Substring will give \ also???????????
Regards,
Kumar
September 6, 2012 at 3:17 am
i have unable to set this expression in derived column.Pls help me..
select convert(varchar(4),month(getdate()),105) + convert(varchar(4),year(getdate()))
Regards,
Kumar
September 6, 2012 at 3:32 am
Derived columns in SSIS do not use T-SQL syntax - they use SSIS Expression syntax, which is a bit like C#. So no selects, converts etc. You just need to know the column name and start positions/lengths.
Have a look at some more examples on-line & you'll see what I mean.
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
September 6, 2012 at 3:36 am
I'm a bit unclear of your requirements but I assume you want to extract the Month and Year from a given date and create a string from the components in the format YYYYMM.
If so try this:
SELECT CAST(YEAR(GETDATE()) AS NVARCHAR(4)) + RIGHT('0' + CAST(MONTH(GETDATE()) AS NVARCHAR(2)),2)
Good luck!
:exclamation: "Be brave. Take risks. Nothing can substitute experience." :exclamation:
September 6, 2012 at 3:41 am
Robin Sasson (9/6/2012)
I'm a bit unclear of your requirements but I assume you want to extract the Month and Year from a given date and create a string from the components in the format YYYYMM.If so try this:
SELECT CAST(YEAR(GETDATE()) AS NVARCHAR(4)) + RIGHT('0' + CAST(MONTH(GETDATE()) AS NVARCHAR(2)),2)
Good luck!
No - this is not how SSIS derived columns work. The formula for a derived column can be as simple as
SUBSTRING( «character_expression», «start», «length» )
where character expression is typically a column name (in square brackets.)
The absence of evidence is not evidence of absence
- Martin Rees
The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
- Phil Parkin
September 6, 2012 at 3:43 am
Thanks Phil, I saw your reply just after I posted mine...
Doing SSIS research as we type...
:exclamation: "Be brave. Take risks. Nothing can substitute experience." :exclamation:
September 6, 2012 at 3:44 am
Why not consider storing as a DATE data type and then convert to the said format when required. Don't understand why you would want to store as int? What's the reason?
September 7, 2012 at 9:26 am
My date column is called periodbegin. The derived column is like this:
YEAR(PeriodBegin) * 100 + MONTH(PeriodBegin)
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply