Link to home
Start Free TrialLog in
Avatar of team2005
team2005

asked on

How to exit stored procedure when records=0

Hi!

How do i exit a stored procedure in sql. When records in a table is 0
ASKER CERTIFIED SOLUTION
Avatar of Cluskitt
Cluskitt
Flag of Portugal image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Actually, if select count>0 then you should print 'Found records'. But it's pretty much the same as my solution, only I used a variable to store the count number.
You are right @cluskit. i did not see your solution and posted it.
Avatar of Anthony Perkins
There many ways to do this.  Here is one way:

IF NOT EXISTS (SELECT 1 FROM YourTableName)
     RETURN

-- Rest of you code here

Unfortunately, without knowing more details it is difficult to be more precise.
Avatar of team2005
team2005

ASKER

thanks