views:

82

answers:

3

I've created a SSIS package, in which I'm calling 2 sp's with a single parameter each. So how to call this package inside a stored procedure by passing a value to as parameter to that package and stored procedure dynamically.

+1  A: 

It would be better to create a Job, and then start that from within your procedure. Otherwise you'll need to start your SSIS package using xp_cmdshell, which many consider bad to use (security risks).

EXEC msdb.dbo.sp_start_job N'YourJobNameHere';

try looking at Running SSIS package programmatically which covers all of the following methods:

  • Run package programmatically using SSIS Object Model
  • Start DTEXEC.EXE process. DTEXEC is command line utility for executing SSIS packages
  • Use SQL Agent. You can configure an Agent job to run your package
  • Use some other utility to start DTEXEC for you
  • Create a custom application that will run the package

EDIT based on OP saying they can't pass a value into a job

if you won't have multiple people trying to run this package at one time, you can insert your values into a special table that the stored procedures (within your package) can select out and use. If you have multiple people trying to run the package at the same time, you can create a queue table, where the job pulls the needed parameters from this queue table and then runs the package, when it is finished it pulls the next set, etc.

KM
A: 

I cant do that in a stored procedure because i cant pass a variable to a job , so i need to run or execute the package itself where in i can pass a parameter to the package programatically, so pls help me regarding this...

if you won't have multiple people trying to run this package at one time, you can insert your values into a special table that the stored procedures (within your package) can select out and use.
KM
A: 

May be you can run the package using the DTExec.exe utility in command line mode. Check Jamie Thomson's blog.

Ex:- /SET \package\DataFlowTask.Variables[User::MyVariable].Value;newValue

Also check this MSDN page

Faiz
I think DTExec.exe is SQL Server 2008 only
KM
No it's not. Check MSDN.
Faiz
@Faiz, yea duh. I could not find in my local 2005 Books Online, but your link shows it is in 2005, I then noticed I was filtering my local BOL searches, when I changed that I could find it.
KM