SSIS-Export scripts from all the SQL Tasks to one file - c#

I have very big SSIS processes that contain a lot of SQL Script Tasks.
I want to export the content of all the SQL Script Tasks to one file
by c# code.
I looked for code but I didn't find.

According to KeithL's comment:
You can open the file with the .dtsx extension of the project
And take all the elements named SQLTask: SQLTaskData The statment is in the attribute SQLTask: SQLStatmentTask

Related

Migrate console C# to SSIS Script Task

I have a C# console app that reads Excel data and reformats it/cleans it up. Finally, app writes data to 2 different CSV files. This console app. has :
Program.cs - contains Main method.
Row.cs - properties that split each row of data into separate columns.
Locations.cs - properties for working with locations (data is divided by regions/locations).
LocationsBuilder.cs - contains main logic where data cleaning and transformation occurs.
I would like to migrate all of the C# code into an SSIS C# Script Task, not sure how to do this as Script Task code seems to only 1 use 1 file for all code.
I would like, if possible, to have all code in 1 script so it works in SSIS Script Task.
SSIS is a platform for ETL work. You can archive Excel to CSV format.
How to do it
1. Open Integration Services project / SQL Server Data Tools (SSDT)
2. Create a new SSIS package
3. Add data flow and add those 2 files as datasource
4. Add control flow accordingly if you have any conditional logic in console applicaiton.
5. Add output destination as CSV ouput
6. That's it
You can keep your code as it is.
In the SSIS designer add a script task component, and copy all classes code inside the script (You can create multiple class inside one cs file or add new classes to the project). And copy the main method code inside the main function in the script.
Or you can create a class library and use it inside the script task code.
Helpful links
how to create a class and methods inside a C# script task

Copy Files from Multiple Sources to Multiple Destination at the same time

I have written a code to copy all files in a directory using c# to a particluar location.I am calling that exe using a .bat file for this process.
The problem is there are n number of sources and n number of destinations and this batch job at a time only copy files from one location to another one.
Is there any way to copy files through a .bat file or using script or even using .net technology from multiple sources to multiple destination?
Copying file from one location to another is easy but i want to copy files from multiple locations at the same time.
Please help me for making this possible.
Create a class called CopyThread which inherits from the Thread class. Add source and destination member to them along with setters. When you create a CopyThread object make sure you set its source and destination values. When you start the thread, it should copy all files from source to destination.
You can have one solution for that,use "command line parameters" to take source and destination path as input to your program and from a batch file call your program multiple times with diffrent parameters. If your sources and destinations are dynamic you have to write small batch program to take inputs for source and destination and call your program with the given inputs as parameters.

Running the ADO.net program at regular interval

I have a sql serevr database in a remote system .I am using ADO.net to bring that database table values into my local mysql server .
Now i want to fetch data from remote db into my local db every 15 min .I think this will involve running the program every 15 min.Please suggest if there is any better way .I want to make it automatic.
I tried with putting the package.dtsx in schedule task . It doesnt work .I think we can make an exe file and then run it
Can you tell me how do i make an exe file?
How do i do this.
Thanks
Since you've tagged your question with Visual Studio 2008, I'll assume you have that.
Create a new project of type Console Application. If you add your code to that project and compile it, the result will be a .exe file which you can run as a Scheduled task.
However, since you are talking about a .dtsx package, another option would be to add your .dtsx package as a scheduled job in the server you are trying to import data to.
Read this on how you schedule a job in SQL Server.

Put file connection to variable on SSIS

i want to do extract zip files on SSIS 2008, using execute process task. I've got confused because Arguments just can do 1 file process and 1 working directory. But i want to an Arguments and a working directory changes dynamic according to SQL table which is give the value for path on Arguments and Working directory. What should i do?
If you wants to pass those values dynamically, then pass the values through varaibles
The operations provided by the File System task target individual file system objects. To
use it against multiple objects, you should use the Foreach Loop Container.
Just google for examples, you should find several

Can you re-use code in SSIS? Can you programmatically change source/target?

I have about 10 different csv files that I need to parse and transform and load into sql server.
I don't want to create 10 different ssis packages for this, would it be possible to create a single SSIS package that I could create 10 different instances of, and simply alter a config file so that it pulls from the correct source csf file and saves to the correct table?
Is it also possible to create re-usable parts of code that would do things like email a report of what was loaded, what had errors and what the erros were etc. There are other parts that I am sure I could re-use between the 10 different files that need to be parsed.
Also, is modifying and deploying a ssis package painful?
This question is same as the below one. I got a solution for that and it really helped me. Hope it will help you.
Best Way to ETL Multiple Different Excel Sheets Into SQL Server 2008 Using SSIS

Categories