data type for a field in sql server

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • siri11
    New Member
    • Sep 2007
    • 38

    data type for a field in sql server

    hi..
    My application is in c#.net (windows app) MS Visual studio 2005 ,version 2.0
    Backend - Sqlserver

    can anyone plzz suggest me as to how to assign a datatype in sql server for a column(field) which should accept decimal,double or float data as per the result which is obtained in front end.
    The problem is I have given the "Float" datatype to this field.And for ex: If the result is 12.56 then it is storing the value as 12.560000419616 7 in the Database.

    And again when I display this value,it is showing this long number on screen which looks very incorrect.
    And if I give the datatype as Numeric(15,5) for the column(field) in sql server,so that after decimal point it can store 5 digits, another problem is arising that is.If for ex:If I enter 12.56 then it is storing the value as 12.56000 in the database.

    Which datatype should I choose so that it stores the exact value (i.e whatever I enter) into database without any changes.
    Plzzzzzzzz help..

    siri
  • DrBunchman
    Recognized Expert Contributor
    • Jan 2008
    • 979

    #2
    Depending on whether you need to manipulate this value as a float within the database you could just store it as a varchar and convert it to whatever type you require in your code once you've read it back.

    Dr B

    Comment

    • Delerna
      Recognized Expert Top Contributor
      • Jan 2008
      • 1134

      #3
      I don't know about anyone else but if I have a field of type float,
      If I enter 12.56 then 12.56 is what gets saved
      if I enter 12.5600005 then 12.5600005 is what gets saved

      ???

      Comment

      Working...