Solved

T-SQL – Real of Decimal datatype?

Posted on 2014-11-09
6
121 Views
Last Modified: 2014-11-10
Dear experts,

I have an SQL 2008R2 database with a filed in it which is now Money datatype. But it look I’ll need to store more than 4 digits and as you know it is limit to for example 0.2345, but now I should be able to write a value like 0.234567 (up to 10 digit depends of customer precision selected).

So my question is – what data type I should select in SQL ? Decimal or real or float? This table is expected to have milions of records in few years and will be heavy used.

This amount will be used for :
1) A lot of Sum over it
 2)Delete other Money value to this value and then and then multiple by this value – 10 times rather than 1)

I think for now to use Decimal – like (12,9)
0
Comment
Question by:dvplayltd
  • 3
  • 2
6 Comments
 
LVL 65

Accepted Solution

by:
Jim Horn earned 500 total points
ID: 40431978
>I should be able to write a value like 0.234567 (up to 10 digit depends of customer precision selected).
numeric(11, 10) if we're talking only a single number left of the decimal, and up to 10 digits after.
The 11 can go as high as 38 total digits.

decimal and numeric are functionally the same

float and real are approximate data types, and I haven't had experience with this but it would scare most uses away from it.
0
 

Author Comment

by:dvplayltd
ID: 40431985
To Jim,

Thanks for your time. The value may be 99.23456 that is why 12,9.

So you tell me to use numeric(12,9) instead decimal(12,9) ? This is different types ?
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 40431989
Functionally they're the same animal.  Not sure why they both exist though, my guess would be backwards compatibility.
0
Efficient way to get backups off site to Azure

This user guide provides instructions on how to deploy and configure both a StoneFly Scale Out NAS Enterprise Cloud Drive virtual machine and Veeam Cloud Connect in the Microsoft Azure Cloud.

 
LVL 10

Expert Comment

by:HuaMinChen
ID: 40432005
Hi,
You can have more decimal precision by using the data type like
decimal(23,7)
0
 

Author Closing Comment

by:dvplayltd
ID: 40432017
10x
0
 
LVL 65

Expert Comment

by:Jim Horn
ID: 40432636
Thanks for the grade.  Good luck with your project.  -Jim
0

Featured Post

Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

Question has a verified solution.

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

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
In this article I will describe the Copy Database Wizard method as one possible migration process and I will add the extra tasks needed for an upgrade when and where is applied so it will cover all.
This Micro Tutorial will give you a basic overview how to record your screen with Microsoft Expression Encoder. This program is still free and open for the public to download. This will be demonstrated using Microsoft Expression Encoder 4.
Sending a Secure fax is easy with eFax Corporate (http://www.enterprise.efax.com). First, just open a new email message. In the To field, type your recipient's fax number @efaxsend.com. You can even send a secure international fax — just include t…

863 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now