Re: taking off decimals

From: Louis Davidson (dr_dontspamme_sql_at_hotmail.com)
Date: 11/03/04


Date: Wed, 3 Nov 2004 15:19:56 -0600

This sounds like the datatype in the grid is treating it as a generic
number, rather than as an integer. Since it shows up in Query Analyzer as
an integer, it is probably something you will have to do in the client.

One thing not yet checked, is the datatype of each of the FieldN values
integer, or are they numeric or real? If they are not integers, then cast
the whole thing as an integer, like:

select cast(sum(categoryId) + sum(categoryId) as int) as sumCategories
from northwind..categories

-- 
----------------------------------------------------------------------------
Louis Davidson - drsql@hotmail.com
SQL Server MVP
Compass Technology Management - www.compass.net
Pro SQL Server 2000 Database Design -
http://www.apress.com/book/bookDisplay.html?bID=266
Note: Please reply to the newsgroups only unless you are interested in
consulting services.  All other replies may be ignored :)
"Ken" <Ken@discussions.microsoft.com> wrote in message
news:19A60486-1ECA-45B4-B82F-2C7DC0B8C839@microsoft.com...
> I have a View with some calculated fields
>
> SUM(Field1) - SUM(Field2) - SUM(Field3) as Total
>
> When I see the result in the view it has no decimals eg.  9000
>
> but when I retrive the value (via SQLDataReader bind to a DataGrid) it
shows
> the number with decimals eg. 9000.00000  and I donīt want decimals to be
shown
>
> Is there a way to do it via the Data Base or it has to be done via My
> Application?
>
> ken
>
>
>
>


Relevant Pages

  • Re: Why does SQL Server round numbers of double type?
    ... Did you define a scale for your numeric datatype? ... > I already use numeric data type, but it still stores the value as integer. ... >> An INTEGER is just that - no decimals will be stored. ... See SQL Server Books Online for details of the available ...
    (microsoft.public.sqlserver.programming)
  • Re: Format the column with
    ... SQL Server returns meta-data with the result set. ... datatype for each columns. ... A tool like Query Analyzer uses this meta-data to define the length of ...
    (microsoft.public.sqlserver.server)
  • Re: I can not read a small file from NTEXT field in the database
    ... new XML datatype instead. ... Are you simply storing the contents of the XML file, ... That wouldn't be a ntext ... If you're working with SQL Server locally, ...
    (microsoft.public.dotnet.framework.aspnet)
  • Re: Precision and Scale innacuracies when dividing
    ... When I try to use a cast to DECIMALthen only 17 digits to the right ... same 17 decimals, but only the first 12 or so have a value. ... SQL server is capping the ... > divisor), ...
    (microsoft.public.sqlserver.programming)
  • Re: I need some serious help
    ... Tibor Karaszi, SQL Server MVP ... > The result of a CASE need to be of the same datatype. ... Int is higher than the string datatypes, and the string 'David' cannot be converted ... > integer so you convert them to appropriate strings. ...
    (microsoft.public.sqlserver.server)