Easy Question: Best DataType for "31.2"

I have percentages I want to use in SQL Server.  The format I want is ##.#, so example numbers are...

10 (or 10.0)
100 (or 100.0)

The numbers will be positive, never more than 1 decimal is needed, and the number will always between 0 and 100.

What is my best datatype to use for such numbers?  I could use a smallint, and multiply by 100 to get the precision I want.  Or do I want to use a float, real, decimal, numeric, etc?  Obviously I want to use as few bytes as possible and have this data still fully storable, and functioning as numbers.
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

You should use decimal(4,1). Your largest number from your example is 100, so I use a precision of 4 and a scale of 1 - since you only want one decimal place).

Decimal and numeric are data types that capture exact numbers. Float and real are used to capture approximate numbers.

rebiesAuthor Commented:
Thanks LandyJ.  Can you explain a tiny bit more.  How many bytes will that consume?  I don't exactly understand the decimal format and how many bytes it uses.  It's easy with a smallint because it always consumes 2 bytes.
Sorry, quick on the draw.  Didn't fully catch the "few bytes as possible" part.  To expand my answer a little:

decimal(4,1) will cost you 5 bytes.  Smallint will only be 2 in storage, but you have the extra calculations:
declare @pct decimal(4,1)
SET @pct = @smallintfld / 100

Plus, other considerations are that a decimal(4,1) will do auto rounding.  @pct = 99.958 will end up being 100.0.  If you were going to do that anyway, you're all set.  If you want 99.9, you have to do some other number gymnastics.

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
rebiesAuthor Commented:
Okay, thanks for the answer.  Yes, the question is: do I want more computations on my end, or less storage space to be used.  A conundrum indeed.

Thanks though as I now think, do to rounding, that you are right and decimal(4,1) is the solution!

It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft SQL Server

From novice to tech pro — start learning today.