Solved

Run Stored Procedure inside another SPROC and passing parameters

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

Optimizing Cloud Backup for Low Bandwidth

With cloud storage prices going down a growing number of SMBs start to use it for backup storage. Unfortunately, business data volume rarely fits the average Internet speed. This article provides an overview of main Internet speed challenges and reveals backup best practices.

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 …
International Data Corporation (IDC) prognosticates that before the current the year gets over disbursing on IT framework products to be sent in cloud environs will be $37.1B.
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed
Using examples as well as descriptions, and references to Books Online, show the documentation available for datatypes, explain the available data types and show how data can be passed into and out of variables.

863 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

20 Experts available now in Live!

Get 1:1 Help Now