Click here to monitor SSC
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


Export data to flat file based on field once.


Export data to flat file based on field once.

Author
Message
Grass
Grass
SSC Rookie
SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)

Group: General Forum Members
Points: 45 Visits: 342
Hi all,

I have a table that is selecting all the fields from the table and exporting to flat file in SSIS. One of the field in the table "Sent" is set to "0" by default. So when the SSIS package runs the query will set the field "Sent to "1" before moving the data to flat file. My question is how should I enforce the SSIS process to not send the data again after the field is set to 1. The process should only move the data to flat file once based on the "Sent" field. If the SSIS process runs again it should either fail or run with no data move to file.Please reply if anyone know regarding this.

Thanks.
Andrew G
Andrew G
SSCrazy
SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)SSCrazy (2K reputation)

Group: General Forum Members
Points: 2012 Visits: 2229
I might not totally understand the requirements here, but couldnt you just use a TSQL task to import the dataset where it only grabs data where SENT = 0.
eg. SELECT col1, col2, col3 FROM table WHERE sent = 0

Then in the next task, export to flat file.

Then the next task update sent = 1, however that would be assuming no changes could be made to the input table by other processes during the export process. Otherwise you'll need a 'for each loop' container to run through each row in the resultset from the first task, updating sent = 1 based on the primary key. The loop can be linked to the first tsql task and the export task in the control flow so that the update only occurs after successfully writing to the flat file.
Grass
Grass
SSC Rookie
SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)

Group: General Forum Members
Points: 45 Visits: 342
There is other process that just insert data to this table where 'Sent' column is '0' when other process insert data to the table. Then from their I have to pull data from the table e.g Select col1, col2,col3 from table where 'Sent' = 0. I didn't understand clearly, you said in first sql task Select col1, col2,col3 from table where 'Sent' = 0. then in second step use data flow task? Where should I update the column 'Sent' = 1? Is this before moving the data to flat file? How to write this? Also, if I run the process again with same data that update the column ' Sent' = 1, is this going to create file with same data again or not? If it is not then that will be right. Please reply.

Thanks,
Calibear
Calibear
SSC Veteran
SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)SSC Veteran (221 reputation)

Group: General Forum Members
Points: 221 Visits: 132
How often is data written into this table? Is it on a schedule? This might help determine how you would deal with exporting/updating the data.

--------
For SQL Tips, check out my blog: http://lantztechknowledge.blogspot.com/
You can also follow my twitter account to get daily updates: @BLantz2455
Grass
Grass
SSC Rookie
SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)SSC Rookie (45 reputation)

Group: General Forum Members
Points: 45 Visits: 342
Data runs on a daily basis from different processes which insert the data into the table.Yes, it runs every morning as schedule. once it is insert into this table the 'IsSent' by default set the data to '0'. From there, it will pulls out from the table and write to a flat file. As it pulls out the field 'IsSent' set to '1'. So,I want only the data which set to 1 should pull out from the table.With that means, if there is data already pulled out before. I don't that to pull again with the new data.
Go


Permissions

You can't post new topics.
You can't post topic replies.
You can't post new polls.
You can't post replies to polls.
You can't edit your own topics.
You can't delete your own topics.
You can't edit other topics.
You can't delete other topics.
You can't edit your own posts.
You can't edit other posts.
You can't delete your own posts.
You can't delete other posts.
You can't post events.
You can't edit your own events.
You can't edit other events.
You can't delete your own events.
You can't delete other events.
You can't send private messages.
You can't send emails.
You can read topics.
You can't vote in polls.
You can't upload attachments.
You can download attachments.
You can't post HTML code.
You can't edit HTML code.
You can't post IFCode.
You can't post JavaScript.
You can post emoticons.
You can't post or upload images.

Select a forum

































































































































































SQLServerCentral


Search