Solved

Run Stored Procedure inside another SPROC and passing parameters

Posted on 2007-03-26
4
358 Views
Last Modified: 2010-03-19
How to I run a stored procedure inside another stored procedure and also pass several parameters to that Sproc?
0
Comment
Question by:Skytide
  • 2
4 Comments
 
LVL 33

Expert Comment

by:knightEknight
ID: 18796735
inside the procedure, do this:

exec myProc2 @param1, @param2, @param3
0
 

Author Comment

by:Skytide
ID: 18796739
is there a way to specify the values of the parameter? Like?
exec myProc2 @param1 = 'dsafads', @param2 = '232', @param3 = '2'
0
 
LVL 33

Expert Comment

by:knightEknight
ID: 18796744
The parameters can be declared inside the procedure or passed into the original procedure:

create procedure MyProc1
  @param1  varchar(80)
as
BEGIN
  declare @param2 int
  declare @param3 varchar(80)

  select @param2 = 99
  select @param3 = 'third param'

  exec myProc2 @param1, @param2, @param3
END
0
 
LVL 10

Accepted Solution

by:
answer_me earned 500 total points
ID: 18798418
yes you can specify same syntax in you stored procedure which you have mentioned
exec myProc2 @param1 = 'dsafads', @param2 = '232', @param3 = '2'

but remember that @param1,@param2,@param3 must eb the same names which you have specified in your procedure.
0

Featured Post

Better Security Awareness With Threat Intelligence

See how one of the leading financial services organizations uses Recorded Future as part of a holistic threat intelligence program to promote security awareness and proactively and efficiently identify threats.

Join & Write a Comment

In this article I will describe the Backup & Restore method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
Slowly Changing Dimension Transformation component in data task flow is very useful for us to manage and control how data changes in SSIS.
Via a live example, show how to shrink a transaction log file down to a reasonable size.
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

708 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

18 Experts available now in Live!

Get 1:1 Help Now