How to Generate Arithmetic Overflow Error in SQL Server – A Fun SQL Challenge

SAS
4 minute read
0

Ever encountered an arithmetic overflow error while inserting data into a DECIMAL column in SQL Server?

In this SQL puzzle, we intentionally trigger this error by inserting values to Decimal Column and understnad the Behaviour of Decimal


Expected OutPut using MS SQL:

Input Table Script:

CREATE TABLE #ArthOverFlow
(
	ID INT,
	Valuess DECIMAL(10,4)
)

So, Lets see the below insert statments and comment which insert statment triggers the Arthematic over flow error for this table


INSERT INTO #ArthOverFlow VALUES  (1,50000.44542)

INSERT INTO #ArthOverFlow VALUES  (2,50.4454256)

INSERT INTO #ArthOverFlow VALUES  (3,50.445425656)

INSERT INTO #ArthOverFlow VALUES  (4,5000099.454)

Please try to answer the question, if you still not able to get it click below show button to see the answer.







Post a Comment

0Comments

Post a Comment (0)

Popular Posts