Export data to flat file based on field once.

  • 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.

  • 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.

  • 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,

  • 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/[/url]
    You can also follow my twitter account to get daily updates: @BLantz2455

  • 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.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply