[lnkForumImage]
TotalShareware - Download Free Software

Confronta i prezzi di migliaia di prodotti.
Asp Forum
 Home | Login | Register | Search 


 

Forums >

microsoft.public.sqlserver.programming

Decimal Precision limited to 4 digits to right of decimal?

cpnet

3/25/2007 9:15:00 PM

I need to store some values in my SQL Server 2005 database with 4-5 digits
to the left of the decimal and about 14 to the right. I tried creating
columns with the type: decimal(38,19). I would expect this would give me 19
digits to the right and left of decimal. I've copied a value into this
column (in the SQL Server Management studio) that looks like this:

123456789.123456789
and
1.123456789

When I post these to the database then refresh the grid, I see:
123456789.1235000000000000000
and
1.1235000000000000000

I've checked the value of @@MAX_PRECISION, and it's set to 38.

Why is it rounding to 4 digits after the decimal? I've tried with
decimal(36,18) so I'm not maxing things out, and I still only get 4 digits
to the left of the decimal.

Thanks


3 Answers

DickChristoph

3/25/2007 9:39:00 PM

0

Hi

It appears to work for me in SQL 2005. Could it be that you are using a
stored procedure and are not using the same precision on the parameter that
is being inserted?

Create Table TestPrec(Data decimal(38,19))
insert TestPrec values('123456789.123456789')
insert TestPrec values('1.123456789')

select * from testprec
Results in
Data
---------------------------------------
123456789.1234567890000000000
1.1234567890000000000

-Dick Christoph

612-724-9282"cpnet" <cpnet@noemail.noemail> wrote in message
news:emwHTGybHHA.5052@TK2MSFTNGP05.phx.gbl...
>I need to store some values in my SQL Server 2005 database with 4-5 digits
>to the left of the decimal and about 14 to the right. I tried creating
>columns with the type: decimal(38,19). I would expect this would give me
>19 digits to the right and left of decimal. I've copied a value into this
>column (in the SQL Server Management studio) that looks like this:
>
> 123456789.123456789
> and
> 1.123456789
>
> When I post these to the database then refresh the grid, I see:
> 123456789.1235000000000000000
> and
> 1.1235000000000000000
>
> I've checked the value of @@MAX_PRECISION, and it's set to 38.
>
> Why is it rounding to 4 digits after the decimal? I've tried with
> decimal(36,18) so I'm not maxing things out, and I still only get 4 digits
> to the left of the decimal.
>
> Thanks
>
>


cpnet

3/25/2007 11:38:00 PM

0

I was trying to use one of the grids in SQL Server Management Studio to
manually put some test data into my table. After looking at your post I
tried using a SQL INSERT command instead, then it does work ok. So, I guess
the SQL Server Management Studio grids round the data to 4 decimal places
when being used to input data. (They do display with full precision if the
data is already there).

Thanks


Hugo Kornelis

3/28/2007 9:28:00 PM

0

On Sun, 25 Mar 2007 19:38:28 -0400, cpnet wrote:

>I was trying to use one of the grids in SQL Server Management Studio to
>manually put some test data into my table. After looking at your post I
>tried using a SQL INSERT command instead, then it does work ok. So, I guess
>the SQL Server Management Studio grids round the data to 4 decimal places
>when being used to input data. (They do display with full precision if the
>data is already there).

Hi cpnet,

I just tested this on my copy of SQL Server Management Studio, but I
could not confirm this. All decimals I entered were retained.

Did you doube-check that you entered everything correctly? Could it be
related to locale settings (since some countries exchange the meaning of
the comma and the dot symbol in numbers)?

--
Hugo Kornelis, SQL Server MVP
My SQL Server blog: http://sqlblog.com/blogs/hug...