473,387 Members | 1,619 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

set default precision on decimal type?

This one cost me a solid half hour yesterday. I'm wondering why on
earth the default precision for a decimal type is 18,0. Maybe I'm
mistaken. A decimal datatype sort of implies that you'd want something
after the decimal!

Question is, can I set this database-wide? Like all new decimal
datatypes have a precision of 12,6 or something like that? I haven't
seen anything about this in the googling I have done...

Dec 8 '06 #1
3 13641
I wouldn't expect that to be something that can be configured. As to
the default of (18,0) vs some other value, I would never allow a
default to be used so it doesn't strike me as a problem. It is so
much safer, and so simple, to always specify what you need explicitly
that I just can't get interested in the issue.

Roy

On 8 Dec 2006 09:34:18 -0800, "Boot2TheHead" <jc*****@gmail.com>
wrote:
>This one cost me a solid half hour yesterday. I'm wondering why on
earth the default precision for a decimal type is 18,0. Maybe I'm
mistaken. A decimal datatype sort of implies that you'd want something
after the decimal!

Question is, can I set this database-wide? Like all new decimal
datatypes have a precision of 12,6 or something like that? I haven't
seen anything about this in the googling I have done...
Dec 8 '06 #2
Boot2TheHead wrote:
This one cost me a solid half hour yesterday. I'm wondering why on
earth the default precision for a decimal type is 18,0. Maybe I'm
mistaken. A decimal datatype sort of implies that you'd want something
after the decimal!

Question is, can I set this database-wide? Like all new decimal
datatypes have a precision of 12,6 or something like that? I haven't
seen anything about this in the googling I have done...
I think the real question is, why would you NOT want to specify the
precision and scale when you use DECIMAL? If it is really important to
you NOT to specify the precision and scale then create a user-defined
type for it (not something I would generally recommend though).

--
David Portas, SQL Server MVP

Whenever possible please post enough code to reproduce your problem.
Including CREATE TABLE and INSERT statements usually helps.
State what version of SQL Server you are using and specify the content
of any error messages.

SQL Server Books Online:
http://msdn2.microsoft.com/library/m...S,SQL.90).aspx
--

Dec 8 '06 #3
Roy Harvey (ro********@snet.net) writes:
I wouldn't expect that to be something that can be configured. As to
the default of (18,0) vs some other value, I would never allow a
default to be used so it doesn't strike me as a problem. It is so
much safer, and so simple, to always specify what you need explicitly
that I just can't get interested in the issue.
Yes, I entirely agree. If only Sybase and/or Microsoft had agreed.
The defaults of decimal and the character data types are do no help
to the users, but a common source of error.
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server 2005 at
http://www.microsoft.com/technet/pro...ads/books.mspx
Books Online for SQL Server 2000 at
http://www.microsoft.com/sql/prodinf...ons/books.mspx
Dec 8 '06 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

15
by: Ladvánszky Károly | last post by:
Entering 3.4 in Python yields 3.3999999999999999. I know it is due to the fact that 3.4 can not be precisely expressed by the powers of 2. Can the float handling rules of the underlying layers be...
4
by: Roger Leigh | last post by:
Hello, I'm writing a fixed-precision floating point class, based on the ideas in the example fixed_pt class in the "Practical C++ Programming" book by Steve Oualline (O' Reilly). This uses a...
2
by: Brian van den Broek | last post by:
Hi all, I guess it is more of a maths question than a programming one, but it involves use of the decimal module, so here goes: As a self-directed learning exercise I've been working on a...
3
by: James Foreman | last post by:
I'm using DB2 UDB 8.1.2 on Suse linux. Try this: CREATE TABLE testsums (cost_of_sale decimal(7,2), price decimal(9, 2)); INSERT INTO testsums VALUES (10000, 30000); SELECT cost_of_sale/price...
1
by: Julie | last post by:
I have the need to preserve the precision of a user-entered number, but that needs to be stored in a (non-string) floating point variable (such as double or decimal). Due to the internal...
15
by: Donkey | last post by:
Hi, The precision of built-in date type of C is very low. Even using long double float type or double float type, we can only use 12 or 16 digits after the decimal point. What can we do if we want...
2
by: Sam | last post by:
Hi, I would like to be able to read the scale & precision of a decimal type contained in a sql server table from vb.net. I would like to set some properties (like width,format) of a gridview's...
10
by: Artemio | last post by:
Hello all! I just stumbled across a weird problem with precision of a division operation. I am on Mac OS X, GCC 4.0.1. Say I have two float or double numbers, and I want to divide one by...
2
by: Tim | last post by:
Folks, Can anyone thow some clarifying light on the following? I have come across a column with the same name and same data contents defined on different tables, on some the column is defined...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.