![]() | |
![]() |
| | Thread Tools | Display Modes |
#1
| |||
| |||
|
#2
| |||
| |||
|
|
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 |
#3
| |||
| |||
|
|
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 |
#4
| |||
| |||
|
|
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 |
![]() |
| Thread Tools | |
| Display Modes | |
| |