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 2005 Forums
 SSIS and Import/Export (2005)
 Flat file connection manager issue

Author  Topic 

varalakshmi
Yak Posting Veteran

98 Posts

Posted - 2011-12-12 : 04:24:51
Hi,

I have to read data from .CSV file which has 5 columns.
When the source file has more than 5 columns, the package should fail processing the file.

But when the number of columns is more than 5 in the file, the package appends the extra columns with the last column.
Row delimiter is given as {CR}{LR}.

How can this be handled?

Thansk in advance.

- Varalakshmi

ravindra.tsg
Starting Member

2 Posts

Posted - 2011-12-13 : 09:46:30
whether you want to do statically or dynamically. i mean one time process or wt?
statically you can do edit the flat file configuration and you will get the reset columns option reset it and remove the extra column and refresh the meta data. it's fine no issues.

if you want to do handle dynamically then you have to use script task.. there for each column one id will be generating.. i.e lineage id
using that you have to code it in C#.


~Ravi
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-13 : 10:51:35
quote:
Originally posted by varalakshmi

Hi,

I have to read data from .CSV file which has 5 columns.
When the source file has more than 5 columns, the package should fail processing the file.

But when the number of columns is more than 5 in the file, the package appends the extra columns with the last column.
Row delimiter is given as {CR}{LR}.

How can this be handled?

Thansk in advance.

- Varalakshmi


for this you need to create an object of file system inside script task and point it to your file and then inside the script parse first row of file to check number of columns. Depending on whether its 5 or more set value for count variable created inside package.check the value of this variable and throw exception if its > 5
Connect this script task to data flow task which does data transer of file to table (your current data flow task). the constraint for this path will be on success of script task. this will make sure data flow task will execute only if script task is success (ie count<=5). other wise script task will throw an error and entire package will fail.

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
   

- Advertisement -