Home > SQL Server > Set auto rollback transactions due to arithmetic overflow – SET ARITHABORT – SQL Server

Set auto rollback transactions due to arithmetic overflow – SET ARITHABORT – SQL Server


SET ARITHABORT statement allows SQL Server to end the query execution whenever the system encounters arithmetic overflow or divide-by-zero error. This set statement is always on by default. But, we can turn this off. If it is off then we may face poor performance problem and even query optimizer get different query.

Arithbort set statement becomes more effective if we use it with ansi_warnings set statement.

SET ARITHABORT ON + SET ANSI_WARNINGS ON = the query execution will be terminated if the system encounters arthimetic overflow or divide-by-zero error.

pic1SET ARITHABORT ON + SET ANSI_WARNINGS OFF = This will terminate SQL execution and If the errors occur in a transaction then the transaction will be rolled back.

pic2SET ARITHABORT OFF + SET ANSI_WARNINGS OFF = this will display a warning message  and NULL is assigned to the result of the arithmetic operation.

pic3note:  If SET ARITHABORT is OFF, CREATE, UPDATE, INSERT, and DELETE statements on tables with indexes on computed columns or indexed views will fail. So, ARITHABORT must be ON when we create or change indexes on computed columns or indexed views.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: