View Single Post

   
  #3 (permalink)  
Old 02-28-2008, 05:57 PM
Erland Sommarskog
 
Posts: n/a
Default Re: Database design/optimization question

Mike Thompson (begeneric@hotmail.com) writes:
> Quick question - since the values will all be from 1-100, is there any
> performance advantage to using tinyint instead of int?


A caveat. Consider this script:

declare @x tinyint, @y tinyint
select @x = 9, @y = 18
select @x - @y

This script fails with

Server: Msg 8115, Level 16, State 2, Line 3
Arithmetic overflow error converting expression to data type tinyint.

because tinyint does not include negative values.

In your query you have the expression val1 - accuracy, so this could
happen to you, both the value and the accuracy are tinyint.

--
Erland Sommarskog, SQL Server MVP, sommar@algonet.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Reply With Quote