Delete files from different folders, approach plz

  • Hi

    I have a requirement that I need to implement delete logic before loading into it. I have around 10 excel files need to be loaded, each in different folder. Before that I need to delete those files from folders.

    Can someone please tell me the logic in ssis.

  • this should help......

    If there are 10 different files each in different folder, I would suggest a script task with a C# script to delete a file and error out and fail the package(or howsoever you wan to design)

    on error.

    The other way could be :

    Create a variable for path of folder....say src_path

    Bring all your folders as resultset of a sql query....like

    select 'c:\folder1' union select 'c:\folder2' union select 'c:\folder3'

    Load it into a recordset destination(say the var rs)

    Set Up a foreach Loop Container. Drive the iteration based on the rows contained in the recordset variable(look up help on ForeachLoop Container). Map the collection value on each iteration to the variable called src_path.

    Set up a File System Task inside the loop container. Set The 'Operation' as 'Delete File'.

    Drive the Source connection through a variable src_path

    This way, upon completion of the loop, all your fiels ahould be deleted.

    Hope this helps.

  • Thanks for your reply.

    Can you please be in detail, how to lookup the recordset variable from foreachloop container.

  • Can anyone please look into it

  • kishoremania (8/29/2012)


    Can anyone please look into it

    Not until you prove that you have tried. There are plenty of resources available on the Internet for this fairly straightforward task. Come back and post again if you have specific questions. People here won't do your work for you - we're unpaid volunteers.

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

  • I suggest that you search for something like "shredding a recordset in ssis".

    The absence of evidence is not evidence of absence
    - Martin Rees
    The absence of consumable DDL, sample data and desired results is, however, evidence of the absence of my response
    - Phil Parkin

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

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