Interview Questions Answers.ORG
Interviewer And Interviewee Guide
Interviews
Quizzes
Home
Quizzes
Interviews Databases Programming Interviews:BtrieveClipperData ModelingData StructuresDatabase AdministrationDatabase Administrator (DBA)Database AnalystDatabase DeveloperDB DevelopmentEDI/Data Integration ExpertFirebirdHierarchicalIBM DB2InformixJava DatabaseMariaDBMicrosoft Access DeveloperMongoDBMS SQL ServerMySQL ProgrammingNetworkNoSQLObject RelationalPostgrePostgreSQLProgressRDBMSRelationalSQLSQL AdministratorSQL and PL/SQLSQL Notification ServicesSQL server 2008SSRSStored ProcedureSybaseTeradata
Copyright © 2018. All Rights Reserved
MS SQL Server Interview Question:
What Happens When Converting Big Values to Integers?
Submitted by: AdministratorIf 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.
Submitted by: Administrator
-- 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.
Submitted by: Administrator
Copyright 2007-2024 by Interview Questions Answers .ORG All Rights Reserved.
https://InterviewQuestionsAnswers.ORG.
https://InterviewQuestionsAnswers.ORG.