Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Delete folders based on values from recordset using File System Task

Posted on 2011-09-19
5
Medium Priority
?
406 Views
Last Modified: 2013-11-10
Hi,

I'm relatively new to SSISs.

What I currently have is a dataflow task which loads up my folder names into an ADO variable using an OLE DB Source to a record set.

I have a predefined path of where these folder names sit. e.g - "\\myServer\store\"

What I need to do is loop through my recordset and append each folder name to my path and delete that folder using File System Task? e.g. delete "\\myServer\store\Folder1FromAdoVariable", "\\myServer\store\Folder2FromAdoVariable" etc

I have had a look at a ForEach loop container but no success.

0
Comment
Question by:Eamon
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
5 Comments
 
LVL 21

Accepted Solution

by:
Alpesh Patel earned 2000 total points
ID: 36560261
1. Path i sfixed, right?
2. Get Folder name from REcordset.
3. Assign reecordset to Foreach loop
4. Assign field value to variable.
5. Use variable in Folder Connection (Create dynamic connection using expression)
6. delete folder using File System Task.

0
 
LVL 1

Author Comment

by:Eamon
ID: 36560542
I think I have followed your instructions.

I now get an error:
Error: Failed to lock variable "\\myServer\store\1471470" for read access with error 0xC0010001 "The variable cannot be found. This occurs when an attempt is made to retrieve a variable from the Variables collection on a container during execution of the package, and the variable is not there. The variable name may have changed or the variable is not being created.".

Folder "1471470" is coming from my recordset which is good.
0
 
LVL 16

Expert Comment

by:carsRST
ID: 36561640
Could be a scope issue on the variable.

See image (left side).  There's a "scope" section under variables.  Try setting to "Package" if it's not already.


 ssis-script-01.jpg
0
 
LVL 21

Expert Comment

by:Alpesh Patel
ID: 36564812
Please make sure the scope of variable at PAckage level not to be at specific task level otherwise you will not get access of those variables define at task level and want to use at other task.
0
 
LVL 1

Author Comment

by:Eamon
ID: 36565301
I was putting the file path into the variable name rather than the variable value for my source connection.

All appears to be working okay now.
0

Featured Post

NFR key for Veeam Agent for Linux

Veeam is happy to provide a free NFR license for one year.  It allows for the non‑production use and valid for five workstations and two servers. Veeam Agent for Linux is a simple backup tool for your Linux installations, both on‑premises and in the public cloud.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Why is this different from all of the other step by step guides?  Because I make a living as a DBA and not as a writer and I lived through this experience. Defining the name: When I talk to people they say different names on this subject stuff l…
Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
Via a live example, show how to extract insert data into a SQL Server database table using the Import/Export option and Bulk Insert.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

618 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question