Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 executing a stored procedure

Author  Topic 

SQLboom
Yak Posting Veteran

63 Posts

Posted - 2003-11-17 : 03:53:30
Hi,

Can anyone provide the syntax for executing a stored procedure (with parameters) using a variable name, with a return value.

E.g. This works fine...

declare @procname varchar(10)
set @procname = 'procname'
Exec @iReturn = @procname

But when the procedure has parameters, it doesn't

declare @procname varchar(10)
set @procname = 'procname @param1 = 1'
Exec @iReturn = @procname


I need to catch the return value (i.e. @iReturn) after the procedure is executed.

Thanks..

rksingh024
Yak Posting Veteran

56 Posts

Posted - 2003-11-17 : 04:26:00
declare @procname varchar(10)
set @procname = 'procname'
Exec @iReturn = @procname @param1 = 1



Ramesh Singh
Go to Top of Page

SQLboom
Yak Posting Veteran

63 Posts

Posted - 2003-11-17 : 05:50:29
Thanks . . .But my parameter is a also a variable. .. :(. . .how do i do it then. . .
Go to Top of Page

rksingh024
Yak Posting Veteran

56 Posts

Posted - 2003-11-17 : 07:05:28
declare @procname varchar(10), @value int
set @procname = 'procname'
set @value = 1
Exec @iReturn = @procname @param1 = @value
or
Exec @iReturn = @procname @value


Ramesh Singh
Go to Top of Page

SQLboom
Yak Posting Veteran

63 Posts

Posted - 2003-11-17 : 10:37:42
Yup!. .. should have got it earlier. . .Thanks a lot ...
Go to Top of Page
   

- Advertisement -