Solved

Run Stored Procedure inside another SPROC and passing parameters

Posted on 2007-03-26
4
400 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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

Microsoft Certification Exam 74-409

Veeam® is happy to provide the Microsoft community with a study guide prepared by MVP and MCT, Orin Thomas. This guide will take you through each of the exam objectives, helping you to prepare for and pass the examination.

Question has a verified solution.

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

Ever needed a SQL 2008 Database replicated/mirrored/log shipped on another server but you can't take the downtime inflicted by initial snapshot or disconnect while T-logs are restored or mirror applied? You can use SQL Server Initialize from Backup…
The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…

624 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