Throwing Errors in SQL stored procedures

by pietman 13. September 2011 12:41

Best way to do it is as follows:

create function dbo.throwError()
returns nvarchar(max)
as
begin
    return cast('Error here.' as int);
end

and it will throw the following error:

Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value 'Error here.' to data type int.

Tags:

Errors | SQL SERVER

Add c0mment




  Country flag
biuquote
  • Comment
  • Preview
Loading


About ...

pietman celliersPietman Celliers
Bitlink  Ltd
bitlinkit.com