Solved

T-SQL – Real of Decimal datatype?

Posted on 2014-11-09
6
119 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
How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

 
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

PRTG Network Monitor: Intuitive Network Monitoring

Network Monitoring is essential to ensure that computer systems and network devices are running. Use PRTG to monitor LANs, servers, websites, applications and devices, bandwidth, virtual environments, remote systems, IoT, and many more. PRTG is easy to set up & use.

Join & Write a Comment

I have written a PowerShell script to "walk" the security structure of each SQL instance to find:         Each Login (Windows or SQL)             * Its Server Roles             * Every database to which the login is mapped             * The associated "Database User" for this …
After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
In this seventh video of the Xpdf series, we discuss and demonstrate the PDFfonts utility, which lists all the fonts used in a PDF file. It does this via a command line interface, making it suitable for use in programs, scripts, batch files — any pl…
You have products, that come in variants and want to set different prices for them? Watch this micro tutorial that describes how to configure prices for Magento super attributes. Assigning simple products to configurable: We assigned simple products…

705 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

17 Experts available now in Live!

Get 1:1 Help Now