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
 SQL Server Development (2000)
 Stored Proc with If - Else Statement

Author  Topic 

Rita Bhatnagar
Posting Yak Master

172 Posts

Posted - 2002-03-06 : 11:35:01
Hi,
I have a stored procedure where i want to use if else statement.
I have kind of
Create Procedure .....
@PrmNumber varchar(200)
as
Begin
If @prmNumber='*'
do this
Else
do that
End
It was giving me problem so i tried to debug it.
when the first condition was true it hit the first 'do this'
and it hit the second one too.Why it's doing that?
It shouldn't hit the second part.It should come out of the procedure?
Any opinion?
I tried like this too

If
Begin Do this
End
Else
Begin
Do that
End
Still the procedure does the same thing.
Any help is appreciated.




JamesT
Yak Posting Veteran

97 Posts

Posted - 2002-03-06 : 11:48:08
The following works fine for me. Perhaps you could post the exact code?

CREATE Procedure TEMP_TEST
@PrmNumber varchar(200)
as
Begin
If @prmNumber='5'
print 'FIVE'
Else
print 'NOT FIVE'
End

exec TEMP_TEST 5

Go to Top of Page
   

- Advertisement -