Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 How to set length for a numeric column and datetim

Author  Topic 

Varun_2003
Starting Member

1 Post

Posted - 2011-08-06 : 02:41:29

I do have a flat file(csv file) which is extracted and loaded to another flat file by its position. For example I do have 3 columns like Record type, Emp number and date with a position constraint. Like Record type is of length 2 with a data type of alpha , Emp number is of length 6 with a data type of numeric and date with a length type of 26 in the format of yyyy-mm-dd.hh.mm.ss.000000.

So my result in the flat file would look like this

016543092011-08-05.11.08.34.000000
026540392011-08-05.11.10.59.000000

I do have two issues

First is I am not able to set the length of the numeric to 6 when I extract the csv file as when I specify the data type of Emp number as numeric then my length is blocked and only the precision is allowed for me to change in Flat file source and also in the Data conversion too. And the result is that there is more spaces added next to this field which is not needed in my output file

Next one is with the datetime --> i am not able to set the length for this one once i set this column with a data type of date time with precision.

With my current result I get the out put like this (I am not able to avoid the blank spaces which comes in between as I am not able to set the length for both numeric and also date time)


01654309 2011-08-05.11.08.34.000000
02654039 2011-08-05.11.10.59.000000


Please suggest me different ways to handle this issue. I have tried using a staging table in between this process but the issue is still prevailing.

Thanks in advance.

Regards,
varun

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2011-08-09 : 02:27:41
First try to do a select statement, using convert() to get char or varchar values in the needed length.
Then, iinstead of the source table give your select statement as the source of data.


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page
   

- Advertisement -