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)
 DB source to FlatFile - Sequential increment

Author  Topic 

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-01-30 : 14:58:25
Hi,
I have a requirement where I need to write the contents of a table into a flat file destination. All the columns from the table are needed. There is also an extra column , Sequence Number, that needs to be written on the file. It should be sequentially incremented for each record. Is there a way this can be done using SSIS. The table contents cannot be altered.

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-30 : 15:12:03
Load data to Staging table and add identity column and Export to Flat File destination.
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-01-30 : 15:23:07
I thought of this initially. To explain the problem a little further. The table contains records grouped into 3 companies. I have to write 3 separate files for each company. And all 3 files are of same format with their own sequence numbers.So I have used a conditional split based on the value of the company. If I have to create staging table with identity I will have to do it thrice. Is there a way to do it without having to create 3 staging tables.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-31 : 08:30:54
cant you use rownumber transformation?

http://www.sqlis.com/post/Row-Number-Transformation.aspx
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2009-02-02 : 14:02:52
Thanks for all your help. I was able to use the Script Component and add a new column for the sequence in the Flat File.
Go to Top of Page

basicconfiguration
Constraint Violating Yak Guru

358 Posts

Posted - 2010-05-06 : 02:52:36
how did you do it?
Go to Top of Page

vijayisonly
Master Smack Fu Yak Hacker

1836 Posts

Posted - 2010-05-06 : 10:07:44
Based on your other question, my requirement was dfferent. If I remember correctly, I used ROW_NUMBER within my stored proc and updated a staging table and then downloaded thre staging table into the flat file using conditional split.
Go to Top of Page
   

- Advertisement -