dbTalk Databases Forums  

Derived Column in SSIS

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss Derived Column in SSIS in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
rswolff@noemail.noemail
 
Posts: n/a

Default Derived Column in SSIS - 10-10-2005 , 03:37 PM






I'm trying to author a .dts package that will combine two number fields (in
my source MS Access database) to form a date, which would then be stored as a
DateTime in my destination SQL Server 2005.

I'm using the following expression to create the derived colum:

[Day] + "-" + [Month] + "-2005"

Where Day and Month are number columns in my source MS Access Database. I'm
expecting to get a result like: 31-Dec-2005.

The expression I'm using to create this derived field keeps throwing an
"invalid cast exception". Specifically it says, "The datatypes DT_I4 and
DT_WSTR are incompatible with the binary operator +" etc..

How do I cast the [Day] and [Month] fields properly to combine them as a SQL
DateTime?

Reply With Quote
  #2  
Old   
Allan Mitchell
 
Posts: n/a

Default Re: Derived Column in SSIS - 10-10-2005 , 04:18 PM






Your derived column would probably want to look like this

(DT_WSTR,2)DayColumn + "-" + (DT_WSTR,2)MonthColumn + "-2005"


HTH

Allan



"rswolff (AT) noemail (DOT) noemail"
<rswolffnoemailnoemail (AT) discussions (DOT) microsoft.com> wrote


Quote:
I'm trying to author a .dts package that will combine two number fields
(in
my source MS Access database) to form a date, which would then be stored
as a
DateTime in my destination SQL Server 2005.

I'm using the following expression to create the derived colum:

[Day] + "-" + [Month] + "-2005"

Where Day and Month are number columns in my source MS Access Database.
I'm
expecting to get a result like: 31-Dec-2005.

The expression I'm using to create this derived field keeps throwing an
"invalid cast exception". Specifically it says, "The datatypes DT_I4
and
DT_WSTR are incompatible with the binary operator +" etc..

How do I cast the [Day] and [Month] fields properly to combine them as a
SQL
DateTime?


Reply With Quote
  #3  
Old   
Andrew Watt [MVP - InfoPath]
 
Posts: n/a

Default Re: Derived Column in SSIS - 10-10-2005 , 04:19 PM



Hi,

I assume you mean a .dtsx package (SSIS).

Try casting the numeric values which are, presumably, DT_I4 to
DT_WSTR before concatenating. Assuming you are allowed to cast that,
then you are simply concatenating string values, which ought to be ok.

Andrew Watt
MVP - InfoPath

On Mon, 10 Oct 2005 13:37:03 -0700, "rswolff (AT) noemail (DOT) noemail"
<rswolffnoemailnoemail (AT) discussions (DOT) microsoft.com> wrote:

Quote:
I'm trying to author a .dts package that will combine two number fields (in
my source MS Access database) to form a date, which would then be stored as a
DateTime in my destination SQL Server 2005.

I'm using the following expression to create the derived colum:

[Day] + "-" + [Month] + "-2005"

Where Day and Month are number columns in my source MS Access Database. I'm
expecting to get a result like: 31-Dec-2005.

The expression I'm using to create this derived field keeps throwing an
"invalid cast exception". Specifically it says, "The datatypes DT_I4 and
DT_WSTR are incompatible with the binary operator +" etc..

How do I cast the [Day] and [Month] fields properly to combine them as a SQL
DateTime?


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.