numeric data types in sql server

  • Whats the difference between int,float and decimal in sql server.

    WHich data type takes how many bytes?

    What data type i should use to store the following sets of data

    1set----100000,854275,74892734

    2set----6538726.98765923,762.659325

    Thanks.

  • The quickest source of infomration on these and all the data types is SQL Server Books Online. Under the Index tab, go to the "data types-SQL Server, described" entry, then scroll down to "described".

       Philip

     

  • I agree with Phillip on this.  Use the books online and pay attention to how SQL Server usings the various types in calculations.  Size and expected use are the keys to which type you will want to use.

    If the phone doesn't ring...It's me.

  • Books online has all about the different data types and their physical storage sizes.

    For what it's worth though, you will want to use decimal not float for numbers, as float is an APPROXIMATE number, not an exact number. EG:

    select cast(6538726.98765923 as float)

    returns 6538726.9876592299

    select cast(6538726.98765923 as decimal(16,8))

    returns 6538726.98765923


    Julian Kuiters
    juliankuiters.id.au

  • I tend to agree with Julian. It looks as you can use INT (or BIGINT) for the 1st set and DECIMAL for the 2nd set. But first of all, what are you doing with this data? What should it represent and what calculations, if any, are you doing with them, inside SQL Server? Forget about the storage space in the first place.

    --
    Frank Kalis
    Microsoft SQL Server MVP
    Webmaster: http://www.insidesql.org/blogs
    My blog: http://www.insidesql.org/blogs/frankkalis/[/url]

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply