Freek's Blog

SQL en .NET vraagstukken en oplossingen die ik zoal tegenkom
posts - 199, comments - 123, trackbacks - 2, articles - 7

My Links

News

Google analytics script: Locations of visitors to this page

Article Categories

Archives

Post Categories

Image Galleries

Algemene links

MSDN

vb links

t-sql: how to exit a stored procedure

Posted on Thursday, July 15, 2010 4:38 PM

Hi, I want to exit a stored procure when certain conditions are true.
You can use stored proc the RETURN statement for that.
.
..
...

DECLARE @CHECK001 AS INT
SET @CHECK001 = (SELECT COUNT(*) FROM tablename)                  -->create condition

if (@CHECK001 = 0)                                                                                  -->check condition
BEGIN
PRINT
'There are no records to process!'
RETURN                                                                                                      -->exit the stored proc from here
END

...
..
.

Post Comment

Title  
Name  
Url
Comment   

ATTENTION: the code you need to copy is CaSe SeNsItIvE and is required to prevent spam.
Enter the code you see: