Jul
17
Written by:
Steve Gray
7/17/2009 8:58 AM
The code to raise an error in SQL is not all that complicated, but it helps to have a template handy, it saves some typing. Why not just store it in the SSMS template area? I’m a consultant, I work on SQL Servers everywhere. A blog is a much handier place for templates.
Is it just me, or does RAISERROR look misspelled? What happened to that missing ‘E’?
declare @msg varchar(100)
set @msg = 'Error Message'
if @thereIsAnError = 1 begin
raiserror (@msg,16,2)
return
end
As always, I welcome your comments!