Solved

TSQL CASE Statement Error SQLServer 7(Msg 8115, "Arithmetic overflow error converting numeric to data type numeric.")

Posted on 2003-11-28
2
1,302 Views
Last Modified: 2011-09-20
SQLServer 7
Watch out for this one…

Statement Below Works
Select
CASE d.AmPmAll
WHEN 1 THEN 0.5
WHEN 2 THEN 0.5
WHEN 3 THEN 1.0 --CORRECT
END TimeOfDayNum
from  Dayoff d


Statement Below Fails
Select
CASE d.AmPmAll
WHEN 1 THEN 0.5
WHEN 2 THEN 0.5
WHEN 3 THEN 1 --INCORRECT
END TimeOfDayNum
from  Dayoff d

Server: Msg 8115, Level 16, State 8, Line 1
Arithmetic overflow error converting numeric to data type numeric.

The ".0" makes a big difference eh!

FYI - d.AmPmAll is a tinyint field; Posted to save someone else time.
0
Comment
Question by:GJPerkins
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
2 Comments
 
LVL 6

Accepted Solution

by:
lausz earned 20 total points
ID: 9837244
The problem is that you have to manage the same data type for all the case statement ..is for this taht you need to use 1.0-

0
 
LVL 6

Expert Comment

by:lausz
ID: 9837263
I tested your sample in sql 2000 and it works in the two ways. I don't know in 7.
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Everyone has problem when going to load data into Data warehouse (EDW). They all need to confirm that data quality is good but they don't no how to proceed. Microsoft has provided new task within SSIS 2008 called "Data Profiler Task". It solve th…
Recently we ran in to an issue while running some SQL jobs where we were trying to process the cubes.  We got an error saying failure stating 'NT SERVICE\SQLSERVERAGENT does not have access to Analysis Services. So this is a way to automate that wit…
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
This video shows, step by step, how to configure Oracle Heterogeneous Services via the Generic Gateway Agent in order to make a connection from an Oracle session and access a remote SQL Server database table.

710 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question