Call a stored procedure from another stored procedure

Call a stored procedure from another stored procedure

Post by Wassi » Sun, 22 Jul 2001 00:00:53



Hi all

I'm using Sqlserver 2000 .
I would like to know if it is possible to call a stored procedure from
another stored procedure . I'm not in the master database .
If the answer is true would you mind guiving me the syntax.

Thanks for the help in advance.

 
 
 

Call a stored procedure from another stored procedure

Post by Faik Bilge » Sun, 22 Jul 2001 03:42:48


Hi,
Yes, you can call a stored procedure from another. SQL Server supports
also recursion in stored procedure. But, be aware of the nesting level,
which
is 32. For more information refer BOL(Books OnLine). Search for
create procedure, stored procedures.
Good Luck

use pubs
go

/* simple procedure returning a string */
create procedure sp_example1
as

select 'Hello, world'
go

/* stored procedure which calls another one */
create procedure sp_example2
as
/* call the first procedure  */
exec sp_example1

go

exec sp_example2


Quote:> Hi all

> I'm using Sqlserver 2000 .
> I would like to know if it is possible to call a stored procedure from
> another stored procedure . I'm not in the master database .
> If the answer is true would you mind guiving me the syntax.

> Thanks for the help in advance.


 
 
 

Call a stored procedure from another stored procedure

Post by BP Margoli » Sun, 22 Jul 2001 07:07:23


Wassim,

One executes a stored procedure by prefacing it with EXECUTE, for example
...

create procedure spWassim_1 as
 exec spWassim_2
go

-------------------------------------------
BP Margolin
Please reply only to the newsgroups.
When posting, inclusion of SQL (CREATE TABLE ..., INSERT ..., etc.) which
can be cut and pasted into Query Analyzer is appreciated.


Quote:> Hi all

> I'm using Sqlserver 2000 .
> I would like to know if it is possible to call a stored procedure from
> another stored procedure . I'm not in the master database .
> If the answer is true would you mind guiving me the syntax.

> Thanks for the help in advance.

 
 
 

1. Calling a Stored Procedure from a Stored Procedure

I have an Access Application which I am converting to SQL
Server.

I am hoping to duplicate some code which all the records in
in a table.

The The code is somthing like this

UPDATE Employee SET Password = encrypt(Password)

Here is the encrypt() Function Code.

Private Function encrypt(ByVal aString As String) As String

Dim ndx As Integer, encodedString As String, encodedValue As String

        encodedString = ""
        For ndx = 1 To Len(aString)
            encodedValue = Asc(Mid(aString, ndx, 1)) + 127
            If (encodedValue >= 0) And (encodedValue <= 255) Then
                encodedString = encodedString & Chr(encodedValue)
            End If
        Next

    encrypt = encodedString

End Function

How do I duplicate this functionality in a stored procedure?
Michael Jenkins
Control Tech Consulting Inc.
(905) 790-1507

http://www.interlog.com/~jenkinsm

2. HELP. P4W over Access

3. Call a stored procedure in another stored procedure

4. Sorting in SQL

5. Calling a stored procedure by another stored procedure

6. Simple Index question

7. QUESTION: How can I call a Stored Procedure from another Stored Procedure

8. Calling a Stored Procedure from a Stored Procedure

9. Calling a stored procedure within a stored procedure.

10. How do I call a stored procedure from another stored Procedure

11. Calling A Stored Procedure from another Stored Procedure

12. Calling a stored procedure from a stored procedure