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.
Author |
Topic |
cplusplus
Aged Yak Warrior
567 Posts |
Posted - 2015-01-22 : 14:32:09
|
I have teh below logic within my Sp, if condition matched i want to go to last without performing any transaction.is it return? if @ContractID=0 begin How to go to last line of sp so that nothing gets executed on this sp call, since @contractid=0 EndThanks a lot for the helpful info. |
|
cplusplus
Aged Yak Warrior
567 Posts |
Posted - 2015-01-22 : 14:41:35
|
Can i use GOTO SkipActionsand at below at teh end:SkipActions: PRINT 'An error was encountered processing the transaction.'GO |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2015-01-22 : 14:56:08
|
You can use GOTO, however that's considered bad programming. Instead just use RETURN to exit the stored proc.Tara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2015-01-22 : 14:57:00
|
if @ContractID=0 beginPRINT 'An error was encountered processing the transaction.' --you should not use PRINT, instead use RAISERRORRETURNendTara KizerSQL Server MVP since 2007http://weblogs.sqlteam.com/tarad/ |
|
|
viggneshwar
Yak Posting Veteran
86 Posts |
Posted - 2015-01-23 : 06:06:12
|
If you want to use goto method this is the codeif @ContractID=0begin GOTO SkipActionsEndSkipActions:PRINT 'An error was encountered processing the transaction.'GORegardsViggneshwar A |
|
|
viggneshwar
Yak Posting Veteran
86 Posts |
Posted - 2015-01-23 : 06:06:24
|
if @ContractID=0begin Raiserror('An error was encountered processing the transaction.', 16, 1)EndRegardsViggneshwar A |
|
|
|
|
|