Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 SSIS and Import/Export (2008)
 Simple Passing of Variable to Stored Proc

Author  Topic 

qman
Constraint Violating Yak Guru

442 Posts

Posted - 2011-10-05 : 10:31:05
I have a nvarchar variable called batch_id, which was set earlier in my package.

I want to call a Stoed Procedure via SQL task using this variable as a parameter to the SP.

I have set up my SQL task as shown below. The task currently fails.

Result Set: None (SP is designed to return nothing)
Connection Type: valid/working SQL Con Manager
SQLSourceType: Direct Input
Parameter Mapping: variable name = user:batch_id, direction = input, data type = nvarchar, parameter name = @batch_id, parameter value = -1

SQL Statement:

exec dbo.stp_c_TES 'AA','BB', @batch_id
go
exec dbo.stp_c_TES 'CC','DD', @batch_id

Thanks in advance!

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-06 : 09:03:20
make it like

exec dbo.stp_c_TES 'AA','BB', ?
go
exec dbo.stp_c_TES 'CC','DD', ?

and in parameter mapping

Parameter Mapping: variable name = user:batch_id, direction = input, data type = nvarchar, parameter name = @batch_id, parameter value = 0
variable name = user:batch_id, direction = input, data type = nvarchar, parameter name = @batch_id, parameter value = 1


------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

qman
Constraint Violating Yak Guru

442 Posts

Posted - 2011-10-06 : 09:37:02
Thanks Vis, I can only get it to work when I comment out the 2nd call to the SP.

exec dbo.stp_c_TES 'AA','BB', ?
--go
--exec dbo.stp_c_TES 'CC','DD', ?

As soon as I introduce the 2nd call, the task blows up.

Are you able to call 2 SP's from the same task?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-10-06 : 09:39:17
try putting them in separate execute sql

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

qman
Constraint Violating Yak Guru

442 Posts

Posted - 2011-10-06 : 09:42:43
I could always break it into two separate SQL tasks if I had to...
Go to Top of Page

qman
Constraint Violating Yak Guru

442 Posts

Posted - 2011-10-06 : 09:46:09
You typed faster than me.... LOL.
Go to Top of Page
   

- Advertisement -