save real datatype in sql without converting to exponential

  • Hello

    I want to save 999999999 as real data in sql.

    but it saved 1+E09.

    Could you help me how can I save 999999999?

    thanks alot

  • bkshn (9/21/2015)


    Hello

    I want to save 999999999 as real data in sql.

    but it saved 1+E09.

    Could you help me how can I save 999999999?

    thanks alot

    Quick question, do you need an actual number or a floating point approximation of the number?

    😎

  • what is difference between them?

    Could you help me in both?

    thanks

  • If you need precise, use the Numeric or Decimal data types.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • You can use BIGINT Or varchar(Max) Or NVARCHAR(max) for this.

    please Use below example for ref:

    DECLARE @temptbl TABLE (ID [nvarchar](max))

    INSERT INTO @temptbl (ID)

    VALUES (N'9999999999999999999999999999999999999999')

    SELECT * FROM @temptbl t

  • schaudhary (9/21/2015)


    You can use BIGINT Or varchar(Max) Or NVARCHAR(max) for this.

    No, please don't suggest storing numbers in a varchar field at all, much less varchar(max). I highly doubt there's much interest in numbers over 8000 digits long.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • declare @temptbl table (ID bigint)

    insert into @temptbl(ID)

    values(99999999999999999)

    select *

    from @temptbl

    try the script above. I just used a previously posted script and changed on data type only.

  • I want to save real datatype!!!

  • If you want to save it as REAL you will have to live with 1E+09 as REAL is actually FLOAT(24) and anything 24 or under is only a 7 digit precision so you cant save 999999999 as that's 9 digit precision.

    Unless you go FLOAT(25) or above or use a fixed precision datatype like NUMERIC or DECIMAL.

  • bkshn (9/21/2015)


    Hello

    I want to save 999999999 as real data in sql.

    but it saved 1+E09.

    Could you help me how can I save 999999999?

    thanks alot

    The question here is, do you know what the REAL datatype in SQL Server actually is? Also, what will this column hold? I mean, what is the purpose of the column? You might ne confusing the definition of REAL in the front-end with the definition of REAL in SQL Server and they're not the same. I strongly suspect you want the INT datatype in SQL Server based on what you've posted.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • bkshn (9/22/2015)


    I want to save real datatype!!!

    Why?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass

Viewing 11 posts - 1 through 10 (of 10 total)

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