June 6, 2013 at 10:02 am
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.
June 11, 2013 at 1:46 am
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
June 11, 2013 at 5:00 am
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 ???
June 11, 2013 at 6:23 am
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;
}
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
June 11, 2013 at 2:18 pm
Thank U Phil
Viewing 5 posts - 1 through 4 (of 4 total)
You must be logged in to reply to this topic. Login to reply