I'm trying to programmatically add an Execute SQL task from within a script task of my SSIS package. I know that the Microsoft.SqlServer.Dts.Runtime.Package class has an Executables collection which I can add my new task to but how to I get a reference to the package Im inside of?
It is not possible, SSIS does not support self-modifying packages.
To prevent any attempts of doing what you are trying to do, the task code does not have access to the package API, so you can't obtain reference to Package object from a task. But even if you find a way to curcumvent this - the results are not predictable, as package is not allowed to modify itself at runtime.
If you could describe what you really want to achieve (rather than asking for particular way to do it) - someone might find a way to do it. Maybe you can use child package - it is OK to modify child package before its execution, or maybe it is enough to just change some variables that are used by Execute SQL task later in this package?
As Michael says above, it's not possible to do what you are asking. However, you may be able to find a solution by setting variables at runtime, or by enabling or disabling certain packages at runtime using dtexec. For example:
dtexec /f e:\ssis\master.dtsx /set \Package\YourPackageName.Disable;True
Related
I am using project deployment model to deploy the SSIS(2012) solution. I use a parent package to execute other child packages. What is the best way (or best practice) to pass parameters to child packages?
When should I use Project level Parameters and Master package parameter bindings? What are the Pros and cons with the approach ? Please advise. Thanks!
My personal approach is to use Project Level Parameters for parameters which are common to several if not all of the packages inside your project. For instance, server and database names. This way, I only need to update them in one place.
I would use the package level parameters for parameters which are needed by that package only and would have values specific to that package only.
By the way, if a parameter is set at Project level (Project.params), then you don't need to pass it from Master to child anymore. Child packages can directly use them. You would pass parameters only if the parameter value is generated only at run-time by the parent package.
It is not directly related but I have documented a solution to automated SSIS 2012 deployment and configuration management which you might be interested with. It's a 3-part series. Please find the link to the first one below:
http://vaniecastro.com/2015/07/19/automate-ssis-2012-project-deployment-and-configuration-management-using-powershell-part-1/
I am using SSIS for ETL and I need to monitor a source folder for the source file to be arrived. When ever a file arrives I need to move that file into another location and rename the file and start executing another SSIS Package. Here we don't have an option to use use any other tool to automate the execution. We have only choice to use SQL Server, SSIS.
I need the mechanism and the logic to implement this logic.
I'm assuming that by "File Watcher" you don't mean FileSystemWatcher class in .NET, as there wouldn't be any point in using this class if you're limited to SQL Server and SSIS (you'd need a job with forever-running SSIS package containing ScriptTask with FileSystemWatcher).
The only solution is to create two-step job. First step would contain SSIS package for reading directory content and comparing it to files history log. Second step would contain your main package and would execute only if first steps succeeds or returns value indicating that there are new files to process.
Your answer is here and here. My personal favorite way of doing it is having an infinite loop package. Yet another way of doing it would be to encapsulate the entire logic in an SSIS package and fire it every X minutes. Vary the value of X depending on the urgency.
I have created an SSIS solution (using SQL SERVER 2012) to extract data from ServiceNow. All the tasks are wrapped in a Sequence Container. When I right click on the Sequence Container and click Execute Task the package behaves as expected. It extracts the data from ServiceNow and performs the rest of the etl. However when I click Execute Package from the Solution Explorer the package successfully completes but it does not extract any data from Service Now.
I have played around with settings and different package designs but with no change in behavior. I can execute with true success at the task level but not the package level. This behavior is even apparent after deployment. I can execute with success from the SSISDB but with no data extraction. When I hook the deployed package to a job I still get no data extraction.
My thinking it has to be some kind of bug or hidden proxy setting because I only get true success (with data extraction) when I manually execute at the task level - i.e. the Sequence Container.
I have been using SSIS for a couple years now and have not come across this issue. Hopefully someone can help or have some ideas.
Got it. I needed a break and to think about this clearly. I needed to update the Package Property Delay Validation from False to True. That solved the issue. I guess the SSIS engine needed the extra time to validate the variable and expressions set up within the package.
I am trying to find a way to be able to pass a couple variables into a Windows Task Scheduler task and I can't find the answer anywhere. I'm not even sure it is possible.
The purpose of this task will be to run a batch file, which will call dtexec to run a SSIS package against my SQL server. I need to remote execute the SSIS package and found that this could be done via PsExec on the remote server, calling a scheduled task on the SQL box. I have gotten this method to work well on other packages.
However, I have a task which requires a StartDate and an EndDate for the package. I can explicitly put the dates into the Add Arguments portion of the scheduled task and it runs fine. I need this argument to be dynamic so when some one requests this data, they enter the dates, and it runs using those dates.
I'm expecting I need to put something in the Add arguments field which will allow this to happen, but I can't find the syntax anywhere. As well, how can I set these variables via command line to set them.
I expect the command to look like
C:\PsTools\psexec \SQLBOX schtasks /run /tn SCHEDTASKNAME /tr input variable syntax
Any help or a push in the right direction would be greatly appreciated.
If you want to schedule the SSIS package execution you should create A SQL Server Agent JOB.
YOu will be able to pass variables values to the package using
SET "\Package.Variables[YOUR_VARIABLE_NAME].Value";"\"VARIABLE_VALUE\""
hope this help
For my requirement I need to write Script task from One SSIS package to another. As my server is 64bit machine, when I execute the overriden SSIS package, it throws the error "Binary Script not found". Hence I need to compile the script programmatically in the Parent SSIS package and put the binary code into the another one. I dont know how to compile the Script programmatically.
Let me know how to do that
I don't think you can do this with SSIS. If there's a way to accomplish this using a Parent Package / Child Package architecture, I'm unaware of it.
You can get more flexibility creating packages dynamically in .Net. Although I haven't tried to dynamically compile script task code.
I'm curious: Why not copy the code out of the parent package and paste it into a child package?
:{> Andy
So you need to somehow programatically execute a (Debug>Build). This typically gets around the problem of binary not being found, when you do it manually in VS. Doesn't strike me as possible at runtime though.