views:

15

answers:

1

I have a power function call inside of a sql function. What is the correct way to handle overflow and underflow conditions since I cannot use a Try Catch inside of a function. I am also trying to avoid modifying the ARITHABORT, ANSI_WARNINGS, and ARITHIGNORE settings in the calling code.

GO

CREATE FUNCTION TestPow()
RETURNS DECIMAL(30, 14)
AS
BEGIN
    DECLARE @result FLOAT
    SET @result = POWER(10.0, 300)
    RETURN @result
END

GO

SELECT dbo.TestPow()
A: 

Use a stored procedure with an output parameter instead, that way you can use proper error handling

SQLMenace