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 2005 Forums
 Transact-SQL (2005)
 How to stop the SP processing

Author  Topic 

khufiamalik
Posting Yak Master

120 Posts

Posted - 2008-10-15 : 05:01:47
Hello all,
I have a condition in my SP and I want to stop further processing when this condition is meet during the SP execution.

Can any one explain that how can i Stop further processing????

Can I use Return or break like statements?

Thanks in advance

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-15 : 05:07:15
You've break in t-sql also. but can i ask from where you want to stop execution? and also under what condition?
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-10-15 : 05:07:42

Use Return


Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

khufiamalik
Posting Yak Master

120 Posts

Posted - 2008-10-15 : 05:12:00
When I used Return it gave me the given below error

"A severe error occurred on the current command. The results, if any, should be discarded"

and my Syntax was like
if @lMarginal_Slab_ID=0
begin
Set @opMessage_Code='MSG_E11';
Set @opTotal_Annual_Tax=0;
return
end
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-10-15 : 08:51:00
quote:
Originally posted by khufiamalik

When I used Return it gave me the given below error

"A severe error occurred on the current command. The results, if any, should be discarded"

and my Syntax was like
if @lMarginal_Slab_ID=0
begin
Set @opMessage_Code='MSG_E11';
Set @opTotal_Annual_Tax=0;
return
end


Is this part of a procedure?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-15 : 09:45:56
Still cant understand when you want to break from execution and why
Go to Top of Page

rohitkumar
Constraint Violating Yak Guru

472 Posts

Posted - 2008-10-15 : 11:05:43
quote:
Originally posted by khufiamalik

Hello all,
I have a condition in my SP and I want to stop further processing when this condition is meet during the SP execution.

Can any one explain that how can i Stop further processing????



isn't that a simple IF ELSE condition?
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-10-15 : 11:08:56
quote:
Originally posted by rohitkumar

quote:
Originally posted by khufiamalik

Hello all,
I have a condition in my SP and I want to stop further processing when this condition is meet during the SP execution.

Can any one explain that how can i Stop further processing????



isn't that a simple IF ELSE condition?


that can also be a solution...unless OP explains his actual scenario we're not sure what he's after
Go to Top of Page
   

- Advertisement -