Throwing Errors in SQL stored procedures

Best way to do it is as follows:

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

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.

What's your thoughts on this?


Protected by WP Anti Spam