Float or else?
-
Hi , i have a doubt to choose a datatype in my database.I have a table with 3 fields : 1 - Code (nvarchar) PK;//in this field there is a code to refer a product. 2 - ProductName (nvarchar); 3 - here i have a doubt ,in this field i need to insert a number (percentage) but i don't know if the best choice is the d float(datatype), the purpose of this field is after the Total of some products we use this percentage to increase the Total for example : if the Total is 25.000 USD i need calculate the Total + 25,7% so 25.000 +25,7%. Which is the better datatype to use in this field to calculate the Total ,is it Float(datatype) or isn't?Can you advice me to apply this step in the right way? Thanks so much for your attention. :)
-
Hi , i have a doubt to choose a datatype in my database.I have a table with 3 fields : 1 - Code (nvarchar) PK;//in this field there is a code to refer a product. 2 - ProductName (nvarchar); 3 - here i have a doubt ,in this field i need to insert a number (percentage) but i don't know if the best choice is the d float(datatype), the purpose of this field is after the Total of some products we use this percentage to increase the Total for example : if the Total is 25.000 USD i need calculate the Total + 25,7% so 25.000 +25,7%. Which is the better datatype to use in this field to calculate the Total ,is it Float(datatype) or isn't?Can you advice me to apply this step in the right way? Thanks so much for your attention. :)
Is your data language English, I note you use a comma as a thousand seperator. If Yes then use VARCHAR() instead of nvarchar which supports unicode characters. I use decimal rather than float, there is a slightly larger penalty when using float and IIRC you cannot use a float in an index/constraint.
Never underestimate the power of human stupidity RAH
-
Is your data language English, I note you use a comma as a thousand seperator. If Yes then use VARCHAR() instead of nvarchar which supports unicode characters. I use decimal rather than float, there is a slightly larger penalty when using float and IIRC you cannot use a float in an index/constraint.
Never underestimate the power of human stupidity RAH
-
Mycroft Holmes wrote:
use VARCHAR() instead of nvarchar which supports unicode characters
Wrong way round, and whats it got to do with thousand separators?
nvarchar() supports unicode - I guess the sentence is ambigious. Comma as the thousand seperator indicates non english format, reasonable assumption. All too many people accept the SQL Server default format with no knowledge why it may not be valid.
Never underestimate the power of human stupidity RAH
-
Hi , i have a doubt to choose a datatype in my database.I have a table with 3 fields : 1 - Code (nvarchar) PK;//in this field there is a code to refer a product. 2 - ProductName (nvarchar); 3 - here i have a doubt ,in this field i need to insert a number (percentage) but i don't know if the best choice is the d float(datatype), the purpose of this field is after the Total of some products we use this percentage to increase the Total for example : if the Total is 25.000 USD i need calculate the Total + 25,7% so 25.000 +25,7%. Which is the better datatype to use in this field to calculate the Total ,is it Float(datatype) or isn't?Can you advice me to apply this step in the right way? Thanks so much for your attention. :)
Money Data Type Money is compatible for currency with dollar and cent format. The datatype is accurate to 10 thousand times of the monetary unit. If the field is capable enough to store large aggregates rather than just the largest value, it is recommended to go with Money data type. Also with money, you have the choice to use thousand of separators. Float/Decimal Data Type Float/Decimal is more flexible, not specific to currency. Suppose you have to support 10 numbers and 2 decimals. In this context decimal is a better choice. Also, decimal is more precise( since we can set precision) and scale to numbers. From the above explanations, I think you should go with money data type. :)
Niladri Biswas