SQL Server Forums
Profile | Register | 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
 New Topic  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
5509 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
22744 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  
 New 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.06 seconds. Powered By: Snitz Forums 2000