开发者

how to store 1.4666667 in sql server

How i can read this line from csv in sql server

ad,aixas,Aixàs,06,42.4833333,1.466666

when i do this i got error please tell me about type fo开发者_StackOverflowr these value and a rule to add it into sql database table


Any floating point type, but probably double precision as a compromise between accuracy and storage.

float is generic floating point type that you can specify the precision of.

Data
Type | Range                                                     | Storage

float -1.79E+308 to -2.23E-308, 0 and 2.23E-308 to 1.79E+308       Depends on the
                                                                   value of n

real  -3.40E + 38 to -1.18E - 38, 0 and 1.18E - 38 to 3.40E + 38   4 Bytes

The synonym for real is float(24).

The synonym for double precision is float(53).

Source

If you want more accuracy you should use decimal.


Sounds like your error is possibly due to dirty data in your CSV file, rather than necessarily a problem with your data type...


Without any more information, like the actual error message, your database schema, and how you do your insert, it's hard to say.

I'm not a seasoned expert in database interfacing, so when I run into problems, and if the database engine doesn't throw a reasonable exception, I take baby steps in arriving at a solution. First, I allow fields to be NULL so that I can insert sparse data into a table. Then I pare my INSERT statement down so that I'm doing one field at a time. Keep adding more and more fields into the INSERT statement until it breaks. The point at which it breaks will tell you where to look next.

If all of your fields are TEXT, VARCHAR, or some string type, then the reason why your INSERT statement fails could be that you're not wrapping your string with "s. Or if your floating point fields are actually floats in the schema, maybe you're passing a string instead of the float. In the two databases I've used before (MySQL and SQLite), numbers are not wrapped with quotes.


Nothing to do with languages/character sets and the accent on the 'a' in 'Aixàs' ??


Try using float.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜