Wednesday, March 7, 2012

Decimal data type

If I create a column with data type Decimal(10,4), when a data is being
stored in that column, will it format the data to be Decimal(10,4) ?
For example: if I enter 1.5, will it be 1.5000, or it will stay as 1.5 ?
When I tried it, it stays at 1.5.
Thanks.fniles wrote:

> If I create a column with data type Decimal(10,4), when a data is
> being stored in that column, will it format the data to be
> Decimal(10,4) ? For example: if I enter 1.5, will it be 1.5000, or
> it will stay as 1.5 ? When I tried it, it stays at 1.5.
No it will always stay 1.5 because 1.5000 is just a string
representation of a number. You best handle that in your application.
HTH,
Stijn Verrept.|||"fniles" <fniles@.pfmail.com> wrote in message
news:umjqImN$FHA.2520@.TK2MSFTNGP15.phx.gbl...
> If I create a column with data type Decimal(10,4), when a data is being
> stored in that column, will it format the data to be Decimal(10,4) ?
> For example: if I enter 1.5, will it be 1.5000, or it will stay as 1.5 ?
> When I tried it, it stays at 1.5.
> Thanks.
I'm going to guess that you're looking at the data in Enterprise Manager.
Go to Query Analyser and Select from that table.
In my SQL Server, EM formats it as 1.5 but in QA, 1.500.|||numbers are not stored with a format. format is a matter of display -
e.g., in Query Analyzer look in Tools \ Options \ Connections - see if
Use regional settings is checked.
fniles wrote:
> If I create a column with data type Decimal(10,4), when a data is being
> stored in that column, will it format the data to be Decimal(10,4) ?
> For example: if I enter 1.5, will it be 1.5000, or it will stay as 1.5 ?
> When I tried it, it stays at 1.5.
> Thanks.
>|||"Raymond D'Anjou" <rdanjou@.canatradeNOSPAM.com> wrote in message
news:e3yclwN$FHA.4028@.tk2msftngp13.phx.gbl...
> "fniles" <fniles@.pfmail.com> wrote in message
> news:umjqImN$FHA.2520@.TK2MSFTNGP15.phx.gbl...
> I'm going to guess that you're looking at the data in Enterprise Manager.
> Go to Query Analyser and Select from that table.
> In my SQL Server, EM formats it as 1.5 but in QA, 1.500.
Add an extra 0 to that output.
One rule to remember, SQL does not FORMAT data in tables, it stores data.
It will make your life simpler if you remember that rule.

No comments:

Post a Comment