|
-
Sep 6th, 2006, 09:08 PM
#1
Thread Starter
Fanatic Member
datatype
what datatype in sql 2000/2005 should i use for this numeric input that has two decimal value?
ex. 1.22
If a post has helped you then Please Rate it!
-
Sep 6th, 2006, 10:07 PM
#2
Re: datatype
How many digits to the left of the decimal point? If one, decimal (3,2).
-
Sep 6th, 2006, 11:23 PM
#3
Thread Starter
Fanatic Member
Re: datatype
just 2 digits (right) from the decimal point.
ex. xxxxxx.22
If a post has helped you then Please Rate it!
-
Sep 7th, 2006, 03:53 AM
#4
Re: datatype
We use MONEY - even though it potentially stores 4 digits to the right of the decimal point, it format's nicely to 2 digits with CONVERT() and CAST() functions.
-
Sep 7th, 2006, 10:06 AM
#5
Re: datatype
just 2 digits (right) from the decimal point.
What about LEFT of the decimal point? What is the maximum value that this field can hold?
999,999.99 - use decimal (8,2) -> 8 digits in total (Precision) with 2 decimal points (Scale)
999,999,999.99 - use decimal (11,2) -> 11 digits in total with 2 decimal points
The Precision determines the number of bytes SQL Server will use for this field. The two declarations above will take up 5 bytes and 9 bytes respectively. Max Precision is 38.
Money datatypes require an explicit conversion to character datatypes, ie you must use Cast and/or Convert. Decimal datatypes are implicitly converted by sql server.
Last edited by brucevde; Sep 7th, 2006 at 10:09 AM.
-
Sep 7th, 2006, 10:28 AM
#6
Re: datatype
We use MONEY for several reasons - not like it's important - but I thought I would mention them.
We only use a handful of datatypes - INT, TINYINT, MONEY, DATETIME and VARCHAR().
Based on the old keep-it-simple concept...
MONEY links up nicely with CURRENCY in VB6 ...
but I think that we have recently discovered that CURRENCY is no longer a datatype in VB.Net - so I see a change coming down the road...
-
Sep 8th, 2006, 01:01 AM
#7
Thread Starter
Fanatic Member
If a post has helped you then Please Rate it!
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|