Thursday, March 8, 2012

Call Stored Procedure Within Stored Procedure!

Hi all,
Can i call a stored procedure from within another stored procedure as well
as providing the
required parameters?
If so, can someone give a basic example?
Cheers,
AdamSure you can. You need to use EXEC spName to call the procedure with the
appropriate parameters. Here is a trivial example:
=====
CREATE PROCEDURE sayHello AS
BEGIN
DECLARE @.string NVARCHAR(100)
SET @.string = 'Hello World'
EXEC getMessage @.string OUT
PRINT @.string
END
CREATE PROCEDURE getMessage (@.tcString NVARCHAR(100) OUT) AS
BEGIN
SET @.tcString = @.tcString + '. Welcome on board.'
END
=====
--
HTH,
SriSamp
Email: srisamp@.gmail.com
Blog: http://blogs.sqlxml.org/srinivassampath
URL: http://www32.brinkster.com/srisamp
"Adam J Knight" <adam.jknight@.optusnet.com.au> wrote in message
news:OOkmgLeYGHA.1228@.TK2MSFTNGP02.phx.gbl...
> Hi all,
> Can i call a stored procedure from within another stored procedure as well
> as providing the
> required parameters?
> If so, can someone give a basic example?
> Cheers,
> Adam
>

No comments:

Post a Comment