is it possible to execute a Package with both a job and from .net? how to change the input parameter?
Asked
Active
Viewed 94 times
1 Answers
1
Yes you can execute the SSIS packages using SQL Agent and from a .NET application.
If you need to pass the input parameter then you need to use the SET option while executing through DTEXEC
command line
/SET "\Package.Variables[User::YourVariable].Properties[Value]";"ValueToBePassed"
If you have several parameters to pass then you can use the above the query in a text file and then use the CommandFile
option in DTEXEC
DTEXEC /File "C:\Package.dtsx" /CommandFile "C:\inputOptions.txt"
If your running from .NET .Add a reference to Microsoft.SqlServer.Dts.Runtime.Application
using app=Microsoft.SqlServer.Dts.Runtime.Application;
string pkgLocation;
Package pkg;
DTSExecResult pkgResults;
pkgLocation = @"C:\SSISPackage\YourPackage.dtsx";
app = new Microsoft.SqlServer.Dts.Runtime.Application();
pkg = app.LoadPackage(pkgLocation, null);
pkg.Variables["VariableName"].Value = "VariableValue";
results= pkg.Execute();
Refer my answer in SO.I have used a script task to execute the package but you can use that code in your .NET app
Refer this article for further information