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)
 Question how to exit from a stored proc process

Author  Topic 

reddymade
Posting Yak Master

165 Posts

Posted - 2007-03-07 : 09:19:30
I have the following stored proc and would like to have an exit statement right after the first line, since my company asked me not to run the process, i don't want to comment each line, instead is it possible to have exit statement right after declare, that way i can remove the exit statement when my company again want the process to run. Please help.

Thank you very much for the information.
*****************************************************************
set ANSI_NULLS ON
set QUOTED_IDENTIFIER ON
GO


ALTER PROCEDURE [dbo].[USP_PSendMail]
AS
declare @recipient varchar(255)
declare @subject varchar(255)
declare @mailbody varchar(8000)
declare @emailid int
declare hCx cursor for
Select toemail,emailsubject,body,emailid from tab_netemailsum
where alerttime is null or alerttime <= getdate()
open hCx
fetch hCx into @recipient,@Subject,@mailbody,@emailid
delete tab_ccsnetemailsum where emailid=@emailid
if( @@fetch_status =0)
Begin
if @recipient is not null begin
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'companyMail',
@recipients=@recipient,
@body = @mailbody,
@subject=@Subject
end
End
while @@fetch_status = 0
Begin
fetch hCx into @recipient,@Subject,@mailbody,@emailid
delete tab_ccsnetemailsum where emailid=@emailid

if( @@fetch_status =0)
Begin
if @recipient is not null begin
EXEC msdb.dbo.sp_send_dbmail
@profile_name = 'compamnyMail',
@recipients=@recipient,
@body = @mailbody,
@subject=@Subject
end
End
End
close hCx
deallocate hCx
****************************************************************

harsh_athalye
Master Smack Fu Yak Hacker

5581 Posts

Posted - 2007-03-07 : 09:25:20
There is no EXIT statement, use RETURN instead.

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

- Advertisement -