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
How do i exit a stored procedure in sql. When records in a table is 0
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
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.
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.
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.
ASKER
thanks