posted on Wednesday, February 16, 2005 3:51 PM
by
Knight_Reign
Programmatically creating tasks...
Someone had a question on an internal alias about the names of the “stock” tasks and how to know which is a stock task and which isn't. But, first let me back up a bit and give some history.
When we first started writing tasks, and the SSIS runtime was in its infancy, we had a number of problems related to creating tasks.
- Tasks written in managed code had fully qualified names that were very long and very hard to remember. (They still do)
- Task names were changing a lot. There was a lot of churn.
- Our task creation story hadn't stabilized yet.
- Task versions were changing a lot.
- We were writing a lot of ad hoc testing code.
Because of these issues, it was quite difficult to create a task programmatically. Plus, the code just looked gnarly.
With fully qualified names, the code looks something like this:
TaskHost execPkghost = (TaskHost)pkg.Executables.Add(“Microsoft.SqlServer.Dts.Tasks.ScriptTask.ScriptTask, Microsoft.SqlServer.ScriptTask, Version=9.0.242.0, Culture=neutral, PublicKeyToken=89845dcd8080cc91”);
We wanted some way to shortcut the name. So we came up with stock names.
With stock names, the code to create a task looks something like this:
TaskHost execPkghost = (TaskHost)pkg.Executables.Add("STOCK:ExecuteSQLTask ");
A little easier to read and write, yes? The problem we have now is that there is code out there that uses the stock “monikers”. So, these names are here to stay. However, they aren't available for every task. Only tasks that the Integration Services team writes. They weren't designed to be extensible, but they are still useful. Maybe in a future version, we'll make it possible for everyone to use this convention. But for now, these are the only tasks that support the stock name:
- SQLTask
- ScriptTask
- ExecuteProcessTask
- ExecutePackageTask
- PipelineTask
- FTPTask
- SendMailTask
- MSMQTask
- FileSystemTask
- BulkInsertTask
- ActiveXScriptTask
- XMLTask
- WmiDataReaderTask
- WmiEventWatcherTask
- TransferStoredProceduresTask
- TransferLoginsTask
- ExecutePackageTask
- Exec80PackageTask
- WebServiceTask
- TransferObjectsTask
- TransferDatabaseTask
So, place a “Stock” qualifier before the names you see above like this, “STOCK:WmiDataReaderTask” and you can create the WMI Data Reader task.
Hope this helps.
Thanks,
Universe.Earth.Software.Microsoft.SQLServer.IS.KirkHaselden