dnf999
SSC Eights!
Points: 870
More actions
December 6, 2006 at 6:53 am
#171554
How do I terminate an SP if a particularly field does not exist in the table I am field the SP on.
i.e.
Create Proc xxx
--check if column exists in table
--If doesn't exist, terminate SP and display error message
Else
Continue with SP
Thanks in advance..
ijaz
SSCommitted
Points: 1912
December 6, 2006 at 7:22 am
#676206
You can used a RETURN STATEMENT anywhere in your stored procedure to exits from SP.
There is a RAISEERROR statement to generate the error which you want to display like
RAISERROR ('Field not exists .', 16, 1)
cheers
Steve Jones - SSC Editor
SSC Guru
Points: 736504
December 6, 2006 at 8:13 am
#676241
rao's solution is the best.
if (x = y)
raiserror ()
return
else
-- continue
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply