|
Home >> FAQs/Tutorials >> SQL Server FAQ
SQL Server FAQ - Overflow Errors on Converting Big Values to Integers
By: FYIcenter.com
(Continued from previous topic...)
What Happens When Converting Big Values to Integers?
If you are converting a numeric expression to an integer data type
and the value is too big for integer storage size, you will get an
arithmetic overflow error as shown in the following examples:
-- Overflow error on implicit conversion
DECLARE @x FLOAT(24);
DECLARE @y TINYINT;
SET @x = 12345.12E+00;
SET @y = @x;
GO
Msg 232, Level 16, State 1, Line 4
Arithmetic overflow error for type tinyint,
value = 12345.120117.
-- Overflow error on explicit conversions
DECLARE @x FLOAT(24);
SET @x = 12345.12E+00;
SELECT CAST(@x AS TINYINT);
SELECT CONVERT(TINYINT, @x);
GO
Msg 232, Level 16, State 1, Line 4
Arithmetic overflow error for type tinyint,
value = 12345.120117.
Msg 232, Level 16, State 1, Line 5
Arithmetic overflow error for type tinyint,
value = 12345.120117.
(Continued on next topic...)
- What Is an Expression?
- What Are Arithmetic Operators?
- What Happens to an Arithmetic Operation with Two Different Data Types?
- How To Convert a Numeric Expression from One Data Type to Another?
- How To Convert Numeric Expression Data Types by Assignment Operations?
- How To Convert Numeric Expression Data Types using the CAST() Function?
- How To Convert Numeric Expression Data Types using the CONVERT() Function?
- How To Convert Character Strings into Numeric Values?
- What Happens When Converting Big Values to Integers?
- What Happens When Converting Big Values to NUMERIC Data Types?
- What Are the Mathematical Functions Supported by SQL Server 2005?
- How To Convert Numeric Values to Integers?
- How To Round a Numeric Value To a Specific Precision?
- How To Generate Random Numbers with the RAND() Function?
|