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
 General SQL Server Forums
 New to SQL Server Programming
 Calling stored procedure from another sp

Author  Topic 

Grainne
Starting Member

2 Posts

Posted - 2008-04-29 : 05:56:25
Hi,

I am new to SQL and new to stored procedures!

What I am trying to do is call one stored procedure from another stored procedure. Very simple piece of code but can not get it to work correctly.....

This is the calling stored procedure: sp_TechRiskMandatory. It is calling a stored procedure called sp_Test.

What is happening is that it is executing the line before the "EXECUTE" command and never getting to this line.

If I put the "EXECUTE" command first it will execute this line and not get to the next.

My code is returning out of the stored procedure before finishing executing the remainder of the code....

CREATE PROCEDURE [sp_TechRisk_Mandatory]

@Conclusion varchar(100),
@TechRisk varchar(100)

AS
If (@Conclusion = 'Application/Changed') and ((@TechRisk = " ") or (@TechRisk = "N/A"))

Begin
Select "AsxErrorMessage" = "Technical Risk must be specified"
EXECUTE sp_Test

End
Else
Begin
Select "Looks Good" = " "
EXECUTE sp_Test
End
GO

This is the code for the sp_Test:

CREATE PROCEDURE sp_Test

AS

BEGIN
Select "AsxErrorMessage" = "Test"

END
GO

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2008-04-29 : 07:07:09
I am surprised this even compiles!

What this statement is supposed to do:
Select "AsxErrorMessage" = "Technical Risk must be specified"


Harsh Athalye
India.
"The IMPOSSIBLE is often UNTRIED"
Go to Top of Page

Grainne
Starting Member

2 Posts

Posted - 2008-04-29 : 07:30:02
Sorry, I should have clarified.

I am creating a form in a quality management system called CATSWeb. I am using stored procedures to build the form. On submitting the form the AsxErrorMessage is displayed to the user.
Go to Top of Page
   

- Advertisement -