Du kan bruge CAST til at kaste meningsfuld fejl:
create function dbo.throwError()
returns nvarchar(max)
as
begin
return cast('Error happened here.' as int);
end
Så vil SQL Server vise nogle hjælpeoplysninger:
Msg 245, Level 16, State 1, Line 1
Conversion failed when converting the varchar value 'Error happened here.' to data type int.