MS SQL Server Concepts and Programming Question:
Download Questions PDF

What Happens If an Integer Is Too Big for INT Date Type?

Answer:

If you are entering an INT data type literal with representing an integer value too big for INT data type to store, the SQL Server will give you an arithmetic overflow error. The same error will happen on BIGINT, INT, SMALLINT, and TINYINT data types. Remember that INT data types uses 4 bytes to an integer value between -2^31 (-2,147,483,648) to 2^31-1 (2,147,483,647). The tutorial exercise below gives an example of arithmetic overflow errors.

-- INT value in the range
DECLARE @x INT;
SET @x = 2147483647;
SELECT @x;
GO
2147483647

-- INT value overflow
DECLARE @x INT;
SET @x = 2147483648;
Msg 8115, Level 16, State 2, Line 2
Arithmetic overflow error converting expression to data type int.


Download MS SQL Server Interview Questions And Answers PDF

Previous QuestionNext Question
What Are Out-of-Range Errors with Date and Time Literals?How Extra Digits Are Handled with NUMERIC Data Type Literals?