Solved

Run Stored Procedure inside another SPROC and passing parameters

Posted on 2007-03-26
4
378 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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
JSON is being used more and more, besides XML, and you surely wanted to parse the data out into SQL instead of doing it in some Javascript. The below function in SQL Server can do the job for you, returning a quick table with the parsed data.
Via a live example combined with referencing Books Online, show some of the information that can be extracted from the Catalog Views in SQL Server.
Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.

776 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