Sreedhar Danturthi
Sreedhar Danturthi

Reputation: 7571

Difference between return statements in SQL Stored Procedure

I would like to know the difference between

    IF X= 0 
    BEGIN
         RETURN 
    END

and

    IF X= 0 
    BEGIN
         RETURN 1
    END 

Which is a better practice when used in a Stored Procedure.

Thanks in anticipation

Upvotes: 0

Views: 2440

Answers (1)

Sivakanesh
Sivakanesh

Reputation: 837

Both are equally valid depending on your requirements. If you simply want to exit your procedure then RETURN will suffice. On the other hand if you want to tell the calling procedure the result of the call then you can do RETURN 1 or any other integer.

More on http://msdn.microsoft.com/en-us/library/ms174998.aspx

Upvotes: 1

Related Questions