By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,361 Members | 1,342 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,361 IT Pros & Developers. It's quick & easy.

data type for a field in sql server

P: 38
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.5600004196167 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
Jun 12 '08 #1
Share this Question
Share on Google+
2 Replies


DrBunchman
Expert 100+
P: 979
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
Jun 12 '08 #2

Delerna
Expert 100+
P: 1,134
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

???
Jun 13 '08 #3

Post your reply

Sign in to post your reply or Sign up for a free account.