Reputation: 381
raiserror('Hello world', 16, 1)
if (@@error > 0)
print @@error
Why does it even return 0? If shouldn't allow to do so.
Upvotes: 0
Views: 114
Reputation: 5277
@@Error stores the error for only a single call on the immediate line after the error. See http://technet.microsoft.com/en-us/library/ms188790.aspx Try this
declare @x int
raiserror('Hello world', 16, 1)
set @x=@@error
if (@x > 0)
print @x
Upvotes: 1