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 |
Jonny1409
Posting Yak Master
133 Posts |
Posted - 2007-12-20 : 05:57:39
|
Hello,Is there a SQL equivalent of the VB code 'EXIT SUB' ?Basically I want to check if a row exists in a certain table, and if it doesn't then insert it, but if it does, exit the stored procedure.Thanks, |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2007-12-20 : 06:17:54
|
Use RETURN statement.Harsh AthalyeIndia."The IMPOSSIBLE is often UNTRIED" |
 |
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2007-12-20 : 06:27:41
|
or use IF statementIf not exists(select * from table where...)Begin---your code to insertEndMadhivananFailing to plan is Planning to fail |
 |
|
georgev
Posting Yak Master
122 Posts |
Posted - 2007-12-20 : 08:34:27
|
Just run with me on this......would it not be more efficient to swap the NOT EXISTS for an EXISTS and ELSE statement? George<3Engaged! |
 |
|
|
|
|