1.使用存储过程传递参数,
2.通过DTEXEC命令行适用工具来执行SSIS包即可.
参考:
create proc ssisexec_up
@param1 nvarchar(100)
as
begin
  DECLARE @sqlcmd nvarchar(2000)
  DECLARE @returncode int
  SET @sqlcmd ='dtexec /f "C:\UpsertData.dtsx" /SET \package.variables[myvariable].Value;'+ltrim(@param1)+ ' '
  EXEC @returncode = xp_cmdshell @sqlcmd  
end

解决方案 »

  1.   

    哈哈,我的做法是,先生成SSIS包xxx.dtsx的xxxbak.dtsConfig,再由C#读取,贴换,另存为SSIS包使用的xxx.dtsConfig。
      

  2.   

    使用C#调用SSIS包
    下面是示例:使用带参数的包,首先引入
    using Microsoft.SqlServer.Dts.Runtime;
    然后在程序中为包变量赋值,具体方法代码:private void runetl()
            {
                Console.WriteLine("ETL start...");
                string filepath = installedPath + "\\etl\\Package.dtsx";
                Microsoft.SqlServer.Dts.Runtime.Application application = new Microsoft.SqlServer.Dts.Runtime.Application();
                Package package = application.LoadPackage(filepath, null, true);
                package.Variables["dbservername"].Value = dwservername;
                package.Variables["dbname"].Value = dwdbname;
                package.Variables["varFolderName"].Value = thispath;
                DTSExecResult result = package.Execute();
                if (result.Equals(DTSExecResult.Success))
                    listBox1.Items.Add("ETL success");
                else
                {
                    listBox1.Items.Add("ETL failed");
                    return;
                }
            }