Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Run Stored Procedure inside another SPROC and passing parameters

Posted on 2007-03-26
4
Medium Priority
?
406 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 2000 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

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
It is possible to export the data of a SQL Table in SSMS and generate INSERT statements. It's neatly tucked away in the generate scripts option of a database.
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Via a live example, show how to setup several different housekeeping processes for a SQL Server.

704 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