Behaviour of SET NUMERIC_ROUNDABORT and SET ARITHABORT

This specifies the level of Error Reporting generated when rounding in an expression causes a loss of precision
------------Here SET NUMERIC_ROUNDABORT ON and SET ARITHABORT OFF
SET NOCOUNT ON
PRINT 'SET NUMERIC_ROUNDABORT ON'
PRINT 'SET ARITHABORT ON'
SET NUMERIC_ROUNDABORT ON
SET ARITHABORT ON
GO
DECLARE @Result DECIMAL(5,2),
@Value_1 DECIMAL(5,4),
@Value_2 DECIMAL(5,4)
SET @Value_1=1.1234
SET @Value_2=1.1234
SELECT @Result=@Value_1+@Value_2
SELECT @Result

-------Here SET NUMERIC_ROUNDABORT OFF and SET ARITHABORT ON
SET NOCOUNT ON
PRINT 'SET NUMERIC_ROUNDABORT OFF'
PRINT 'SET ARITHABORT ON'
SET NUMERIC_ROUNDABORT OFF
SET ARITHABORT ON
GO
DECLARE @Result DECIMAL(5,2),
@Value_1 DECIMAL(5,4),
@Value_2 DECIMAL(5,4)
SET @Value_1=1.1234
SET @Value_2=1.1234
SELECT @Result=@Value_1+@Value_2
SELECT @Result

------------------Here SET NUMERIC_ROUNDABORT OFF and SET ARITHABORT OFF
SET NOCOUNT ON
PRINT 'SET NUMERIC_ROUNDABORT OFF'
PRINT 'SET ARITHABORT OFF'
SET NUMERIC_ROUNDABORT OFF
SET ARITHABORT OFF
GO
DECLARE @Result DECIMAL(5,2),
@Value_1 DECIMAL(5,4),
@Value_2 DECIMAL(5,4)
SET @Value_1=1.1234
SET @Value_2=1.1234
SELECT @Result=@Value_1+@Value_2
SELECT @Result

Comments

Popular posts from this blog

System.Data.SqlClient.SqlException (0x80131904): Execution Timeout Expired. The timeout period elapsed prior to completion of the operation or the server is not responding. ---> System.ComponentModel.Win32Exception (0x80004005): The wait operation timed out

Pre login Handshake or Connection Timeout Period

Transparent Data Encryption(TDE) with Master Key and Certificate in SQL Server