Please start any new threads on our new site at http://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

Our new SQL Server Forums are live! Come on over! We've restricted the ability to create new threads on these forums.

SQL Server Forums
Profile | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Exit Sub Equivalent
 Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

Jonny1409
Posting Yak Master

133 Posts

Posted - 12/20/2007 :  05:57:39  Show Profile  Reply with Quote
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
Flowing Fount of Yak Knowledge

India
5581 Posts

Posted - 12/20/2007 :  06:17:54  Show Profile  Visit harsh_athalye's Homepage  Click to see harsh_athalye's MSN Messenger address  Send harsh_athalye a Yahoo! Message  Reply with Quote
Use RETURN statement.

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

madhivanan
Premature Yak Congratulator

India
22864 Posts

Posted - 12/20/2007 :  06:27:41  Show Profile  Send madhivanan a Yahoo! Message  Reply with Quote
or use IF statement

If not exists(select * from table where...)
Begin
---your code to insert
End

Madhivanan

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

georgev
Posting Yak Master

United Kingdom
122 Posts

Posted - 12/20/2007 :  08:34:27  Show Profile  Reply with Quote
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!
Go to Top of Page
  Previous Topic Topic Next Topic  
 Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.16 seconds. Powered By: Snitz Forums 2000