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
 General SQL Server Forums
 New to SQL Server Programming
 Procedure Help!

Author  Topic 

Amber_Deslaurier
Starting Member

40 Posts

Posted - 2010-06-26 : 20:35:37
Hi,

I made a procedure but it has several steps. The 1st one is to check a table and identify if its empty and if so then end the procedure, otherwise continue to the next steps....

what am I missing?

Ty,

Amber.

Syntax Errors:

CREATE PROCEDURE STEP_ONE()

BEGIN

IF TABLE_ONE IS NULL

THEN

END;

ELSE

DEL FROM TABLE_TWO

CALL PROCESS_FIVE();

END IF

END;

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-06-26 : 20:51:32
IF NOT EXISTS (SELECT * FROM TABLE_ONE)
RETURN
ELSE...

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

Amber_Deslaurier
Starting Member

40 Posts

Posted - 2010-06-26 : 21:06:49
thanks i will try it.
Go to Top of Page

tkizer
Almighty SQL Goddess

38200 Posts

Posted - 2010-06-27 : 00:41:07
You're welcome.

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog
Go to Top of Page

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-06-28 : 03:04:17
quote:
Originally posted by tkizer

IF NOT EXISTS (SELECT * FROM TABLE_ONE)
RETURN
ELSE...

Tara Kizer
Microsoft MVP for Windows Server System - SQL Server
http://weblogs.sqlteam.com/tarad/

Subscribe to my blog



Use NULL instead of * to fast query performance

IF NOT EXISTS (SELECT NULL FROM TABLE_ONE)
RETURN
ELSE...


Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER
Go to Top of Page

GilaMonster
Master Smack Fu Yak Hacker

4507 Posts

Posted - 2010-06-28 : 04:57:22
quote:
Originally posted by vaibhavktiwari83

Use NULL instead of * to fast query performance

IF NOT EXISTS (SELECT NULL FROM TABLE_ONE)
RETURN
ELSE...



Doesn't make a difference. The SQL parser removes all column references from an EXISTS early in query execution.

--
Gail Shaw
SQL Server MVP
Go to Top of Page

vaibhavktiwari83
Aged Yak Warrior

843 Posts

Posted - 2010-06-28 : 05:58:26
Yes You are right.. it makes difference if we directly execute select statement..

I confirmed...
Thanks to correct me..

Vaibhav T

To walk FAST walk ALONE
To walk FAR walk TOGETHER
Go to Top of Page

Amber_Deslaurier
Starting Member

40 Posts

Posted - 2010-07-01 : 20:30:46
Thanks!
Go to Top of Page
   

- Advertisement -