Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Delete files from different folders, approach plz Expand / Collapse
Author
Message
Posted Friday, August 17, 2012 2:28 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 5:40 PM
Points: 52, Visits: 201
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.
Post #1346751
Posted Wednesday, August 22, 2012 9:37 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, July 28, 2014 12:04 PM
Points: 35, Visits: 98
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.

Post #1348520
Posted Wednesday, August 29, 2012 12:02 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 5:40 PM
Points: 52, Visits: 201
Thanks for your reply.

Can you please be in detail, how to lookup the recordset variable from foreachloop container.
Post #1351805
Posted Wednesday, August 29, 2012 12:02 PM
Valued Member

Valued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued MemberValued Member

Group: General Forum Members
Last Login: Tuesday, November 18, 2014 5:40 PM
Points: 52, Visits: 201
Can anyone please look into it
Post #1351806
Posted Wednesday, August 29, 2012 12:08 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 1:32 PM
Points: 5,245, Visits: 12,160
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.



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1351809
Posted Wednesday, August 29, 2012 12:10 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 1:32 PM
Points: 5,245, Visits: 12,160
I suggest that you search for something like "shredding a recordset in ssis".


Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.
Post #1351812
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse