SQL Clone
SQLServerCentral is supported by Redgate
 
Log in  ::  Register  ::  Not logged in
 
 
 


HOW TO CREATE DYNAMIC FOLDER TO INSERT EXPORTED FILES INTO ??


HOW TO CREATE DYNAMIC FOLDER TO INSERT EXPORTED FILES INTO ??

Author
Message
Lidou123
Lidou123
SSC-Enthusiastic
SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)

Group: General Forum Members
Points: 133 Visits: 380
Hi All,

In my actual project, my boss asked me to export data from database to csv flat files.

So, as I don't know .net code, I use SSIS File System task and ForEach Loop Container.

I built a package which:
1. Select data filtered by year, month and region
2. Create differents folder to archive files exported like this:
A- Year
B - MONTH
C-REGION
D- csv Files.

One difficulty that I have is to create folder only if it does not exist.

Any help or suggestions would be appreciated.

Thank U.
varun.x.shar
varun.x.shar
Old Hand
Old Hand (301 reputation)Old Hand (301 reputation)Old Hand (301 reputation)Old Hand (301 reputation)Old Hand (301 reputation)Old Hand (301 reputation)Old Hand (301 reputation)Old Hand (301 reputation)

Group: General Forum Members
Points: 301 Visits: 296
Hi,

You can do this using scripting in vb or C# in SSIS script task. There is a beautiful post on this requirement.

http://sqlserversolutions.blogspot.com/2009/01/creating-directory-using-ssis.html


Thanks
Varun
Lidou123
Lidou123
SSC-Enthusiastic
SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)

Group: General Forum Members
Points: 133 Visits: 380
Hi Varun,

Thank U for your answer.

But one difficulty that I have is to create the folder only if it doesn't exist.
Do U know how to implement it with SSIS script task ??

Because I need to:
1- Export data from my database filtered by Region and Month (because of files that I want to export )
I think that I will use a ForeachLoop Container with SSIS DFT task inside it.
And have Region and Month in parameter for the filter clause

2- Create a folder with Month Name only if it doesn't exist (use script task or File system task ???)

3- Create a sub-folder with Region Name only if it doesn't exist (use script task or File system task ???)

4- Export Files in subfolder that I create .

Please can U help me to implement it ???
Phil Parkin
Phil Parkin
SSCoach
SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)SSCoach (18K reputation)

Group: General Forum Members
Points: 18254 Visits: 20404
Here is the code for a script task to check for the existence of c:\temp1. If it does not exist, it is created.

   
public void Main()
{
string folderCheck = @"c:\temp1";
if (!System.IO.Directory.Exists(folderCheck))
System.IO.Directory.CreateDirectory(folderCheck);

Dts.TaskResult = (int)ScriptResults.Success;
}




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

If the answer to your question can be found with a brief Google search, please perform the search yourself, rather than expecting one of the SSC members to do it for you.

Please surround any code or links you post with the appropriate IFCode formatting tags. It helps readability a lot.
Lidou123
Lidou123
SSC-Enthusiastic
SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)SSC-Enthusiastic (133 reputation)

Group: General Forum Members
Points: 133 Visits: 380
Thank U Phil
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