dbTalk Databases Forums  

Convert & Cast in DTS Transformation Scripts?

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


Discuss Convert & Cast in DTS Transformation Scripts? in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
vesta
 
Posts: n/a

Default Convert & Cast in DTS Transformation Scripts? - 10-14-2005 , 03:33 PM






Hi,

I'm importing a space delimited text file into a table that has
specified data types of int and smalldatetime -- which is throwing the
error, "conversion invalid for datatype on column pair" as the source
file is a text file. I don't really care too much about the date, as
it isn't really used and I can change the data type to varchar, but I
do care about the int.

I've never much used the transform option in DTS and I am not really a
scripting type of gal, so cannot figure out how to convert or cast a
string to an int, i.e, something like this?

DTSDestination("program_code") = DTSSource(cast("Col004" as int))

which, of course, does not work.

Or can it not be done?

Vesta


Reply With Quote
  #2  
Old   
SQL
 
Posts: n/a

Default RE: Convert & Cast in DTS Transformation Scripts? - 10-15-2005 , 04:09 AM






Since this is VB Script you have to use CInt

DTSDestination("program_code") = DTSSource(CInt("Col004"))
But it looks like your data is not clean, if something is a number and
stored in a textfile it should import without a problem

http://sqlservercode.blogspot.com/

"vesta" wrote:

Quote:
Hi,

I'm importing a space delimited text file into a table that has
specified data types of int and smalldatetime -- which is throwing the
error, "conversion invalid for datatype on column pair" as the source
file is a text file. I don't really care too much about the date, as
it isn't really used and I can change the data type to varchar, but I
do care about the int.

I've never much used the transform option in DTS and I am not really a
scripting type of gal, so cannot figure out how to convert or cast a
string to an int, i.e, something like this?

DTSDestination("program_code") = DTSSource(cast("Col004" as int))

which, of course, does not work.

Or can it not be done?

Vesta



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

Default RE: Convert & Cast in DTS Transformation Scripts? - 10-15-2005 , 04:45 AM



Hello SQL,

The code below should probably read

DTSDestination("program_code") = Cint(DTSSource("Col004"))

Allan


Quote:
Since this is VB Script you have to use CInt

DTSDestination("program_code") = DTSSource(CInt("Col004"))
But it looks like your data is not clean, if something is a number and
stored in a textfile it should import without a problem
http://sqlservercode.blogspot.com/

"vesta" wrote:

Hi,

I'm importing a space delimited text file into a table that has
specified data types of int and smalldatetime -- which is throwing
the error, "conversion invalid for datatype on column pair" as the
source file is a text file. I don't really care too much about the
date, as it isn't really used and I can change the data type to
varchar, but I do care about the int.

I've never much used the transform option in DTS and I am not really
a scripting type of gal, so cannot figure out how to convert or cast
a string to an int, i.e, something like this?

DTSDestination("program_code") = DTSSource(cast("Col004" as int))

which, of course, does not work.

Or can it not be done?

Vesta




Reply With Quote
  #4  
Old   
SQL
 
Posts: n/a

Default RE: Convert & Cast in DTS Transformation Scripts? - 10-15-2005 , 05:19 AM



You are right, that was my bad

"Allan Mitchell" wrote:

Quote:
Hello SQL,

The code below should probably read

DTSDestination("program_code") = Cint(DTSSource("Col004"))

Allan


Since this is VB Script you have to use CInt

DTSDestination("program_code") = DTSSource(CInt("Col004"))
But it looks like your data is not clean, if something is a number and
stored in a textfile it should import without a problem
http://sqlservercode.blogspot.com/

"vesta" wrote:

Hi,

I'm importing a space delimited text file into a table that has
specified data types of int and smalldatetime -- which is throwing
the error, "conversion invalid for datatype on column pair" as the
source file is a text file. I don't really care too much about the
date, as it isn't really used and I can change the data type to
varchar, but I do care about the int.

I've never much used the transform option in DTS and I am not really
a scripting type of gal, so cannot figure out how to convert or cast
a string to an int, i.e, something like this?

DTSDestination("program_code") = DTSSource(cast("Col004" as int))

which, of course, does not work.

Or can it not be done?

Vesta





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.