Configure 'Execute DTS 2000 Package' Task
What is the best way to dynamically configure the Package ID? What we are doing is using a script to push our DTS from test to live environment and to do that we are recreating the live DTS package, giving it new GUIDs. In the SSIS package I am calling DTS tasks by name and GUID. It would be best if I could just call the DTS task by name and omit the GUID. Is that possible? So looking into this, my options for chaning the SSIS package whenever the DTS GUID changes are: * configuration XML file/ variable or, * expressions Is any one better than the other? Are there other options I am missing? Thanks
February 28th, 2011 1:09pm

Why don't you use Execute DTS task: http://msdn.microsoft.com/en-us/library/ms137907.aspx ?Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
February 28th, 2011 1:11pm

I just added a 'Execute Package' task and all I get to pick from is \Packages\Maintenance Plans. DTS is in \Management\Legacy\Data Transformation Services btw, I don't see a 'Execute DTS' task in 2008 BIDS, only 'Execute DTS 2000 Package ' task. ps. currently all my DTS executions in SSIS are done with a 'Execute DTS 2000 Package' tasks but that task requires a GUID.
February 28th, 2011 1:57pm

If you choose a package stored in the file system you use the name and location of the package.Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
February 28th, 2011 2:10pm

I see. Ours are on the SQL.
February 28th, 2011 2:20pm

I see in turn, you can use DTUTIL's /I switch to generate a new [random] GUID, does that suffice?Arthur My Blog
Free Windows Admin Tool Kit Click here and download it now
February 28th, 2011 2:33pm

Here is my solution: using System; using System.Collections.Generic; using System.Linq; using System.Text; using Microsoft.SqlServer.Dts.Runtime; using DTS; using System.Data; using System.Data.SqlClient; namespace DbHelper { public static class SsisHelper { public static Microsoft.SqlServer.Dts.Runtime.Package RetrievePackage(string fileLocation) { try { Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application(); Microsoft.SqlServer.Dts.Runtime.Package pkg = app.LoadPackage(fileLocation, null); app = null; return pkg; } catch { return null; } } private static bool SavePackage(Microsoft.SqlServer.Dts.Runtime.Package pkg, string fileLocation) { try { Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application(); app.SaveToXml(fileLocation, pkg, null); app = null; return true; } catch { return false; } } /// <summary> /// This method does not run legacy DTS. /// </summary> public static Microsoft.SqlServer.Dts.Runtime.DTSExecResult RunPackage(string package, string servername, string username, string password) { try { Microsoft.SqlServer.Dts.Runtime.Application app = new Microsoft.SqlServer.Dts.Runtime.Application(); Microsoft.SqlServer.Dts.Runtime.Package pkg = app.LoadFromSqlServer(package, servername, username, password, null); Microsoft.SqlServer.Dts.Runtime.DTSExecResult result = pkg.Execute(); pkg.Dispose(); pkg = null; app = null; return result; } catch { return DTSExecResult.Canceled; } } public static bool UpdateExec80PackageTaskId(string dtsxLocation, Guid containerId, Guid oldGuid, Guid newGuid) { Microsoft.SqlServer.Dts.Runtime.Package pkg = RetrievePackage(dtsxLocation); if (pkg == null) return false; bool foundContainer = false; bool foundTask = false; bool matchedTaskId = false; bool pkgSaved = false; foreach (Microsoft.SqlServer.Dts.Runtime.Executable executable in pkg.Executables) { if (executable.GetType() == typeof(Microsoft.SqlServer.Dts.Runtime.Sequence)) { if (Guid.Parse(((Microsoft.SqlServer.Dts.Runtime.Sequence)executable).ID) == containerId) { foundContainer = true; //(((Microsoft.SqlServer.Dts.Runtime.TaskHost)((Microsoft.SqlServer.Dts.Runtime.Sequence)pkg.Executables[7]).Executables[9]).InnerObject as Microsoft.SqlServer.Dts.Tasks.Exec80PackageTask.IDTSExec80PackageTask).PackageID foreach (Microsoft.SqlServer.Dts.Runtime.TaskHost host in ((Microsoft.SqlServer.Dts.Runtime.Sequence)executable).Executables) { Microsoft.SqlServer.Dts.Tasks.Exec80PackageTask.IDTSExec80PackageTask dts80task = host.InnerObject as Microsoft.SqlServer.Dts.Tasks.Exec80PackageTask.IDTSExec80PackageTask; if (dts80task != null) { foundTask = true; if (Guid.Parse(dts80task.PackageID) == oldGuid) { matchedTaskId = true; dts80task.PackageID = "{" + newGuid.ToString() + "}"; if (SavePackage(pkg, dtsxLocation)) { pkgSaved = true; } } dts80task.DisposeComObject(); if (pkgSaved) break; } } } } if (pkgSaved) break; } return pkgSaved; } } }
February 28th, 2011 3:46pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics