Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Trying to execute a procedure within another procedure 1

Status
Not open for further replies.

mbcmike

Programmer
Sep 9, 2005
34
0
0
US
I want to execute a procedure depending on whether or not a paramater is in a particular table:


execute procedure
where not exists
(select * from table
where ssn = @p_ssn
)


Obviously I am doing something wrong here...
 
Hi,

Declare an int variable and assign its value based on the result of your query, then execute your proc based on the variable value.

Code:
DECLARE @var int

IF NOT EXISTS (SELECT * FROM Table WHERE ssn = @p_ssn)
BEGIN
SET @var = 0
END
ELSE
SET @var = 1

IF @Var = 1
EXEC pr_YourProc

Or something similar...

Hope this helps.


Cheers,
Leigh

Sure, if it has a microchip in it, it must be IT... Now what seems to be the problem with your toaster...?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top