Setting precision of a float data type

Posted on 2008-11-14
Last Modified: 2012-05-05
I am trying to create a table with a column of type 'float(24)' in SQL Server 2000. When I do that via Enterprise Manager, the Precision field is grayed out, so I cannot change it from the default value of 53. I tried to create a table running a script like this:

CREATE TABLE [dbo].[MyTable] (
      [X] [float(24)] NULL

but I am getting an error "Cannot find data type float(24).". So I have no idea, how the precision can be defined for this data type. Looks like a simple issue, and because of this it's even more frustrating. Can anybody enlighten me, please?
Question by:nebfis
    LVL 7

    Expert Comment

    Use Decimal(24,6) instead.  I don't believe float has precision.
    LVL 29

    Accepted Solution

    What you are looking for is the data type real.

    According to the documentation, you should be able to use float(24) to get a real, but perhaps that doesn't work in SQL Server 2000.
    LVL 142

    Expert Comment

    by:Guy Hengel [angelIII / a3]
    what kind of data do you want to store, actually?

    Author Closing Comment

    Thank you. Yes, according to documentation it should be possible, and that's what irritates me. It's one of the most confusing pieces of documentation I've recently seen. I can declare a variable to be of type float(12), for example, and it works perfectly fine, but I cannot create a table column of this type. Oh, well...
    In my case I'll have to go with 'real'.

    Using Decimal(24,6) is not a solution because what I need is a number in floating point format.

    I have to be able to store numbers in floating point format.

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Threat Intelligence Starter Resources

    Integrating threat intelligence can be challenging, and not all companies are ready. These resources can help you build awareness and prepare for defense.

    Nowadays, some of developer are too much worried about data. Who is using data, who is updating it etc. etc. Because, data is more costlier in term of money and information. So security of data is focusing concern in days. Lets' understand the Au…
    The Delta outage: 650 cancelled flights, more than 1200 delayed flights, thousands of frustrated customers, tens of millions of dollars in damages – plus untold reputational damage to one of the world’s most trusted airlines. All due to a catastroph…
    Via a live example, show how to backup a database, simulate a failure backup the tail of the database transaction log and perform the restore.
    Viewers will learn how to use the INSERT statement to insert data into their tables. It will also introduce the NULL statement, to show them what happens when no value is giving for any given column.

    779 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now