tags:

views:

125

answers:

5

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 for these value and a rule to add it into sql database table

+1  A: 

Try using float.

Brissles
No. Do not use float unless you actually need a float. If in doubt, then don't use one. http://blogs.msdn.com/b/qingsongyao/archive/2009/11/14/float-datatype-is-evil.aspx
adolf garlic
+2  A: 

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.

ChrisF
No no no. I don't understand why people seem to think floats are a good idea unless they are absolutely essential. http://blogs.msdn.com/b/qingsongyao/archive/2009/11/14/float-datatype-is-evil.aspx
adolf garlic
@adolf - you'll note I specified double precision which is float(53) in SQL. Yes for more accuracy use decimal, but it will take up more storage.
ChrisF
@adolf - I could just as easily say I don't understand why demimals are a good idea unless they are absolutely essential. It means little. It's all about using what is appropriate. Decimals aren't magic and I can give you a list of reasons they are bad in many cases.
Kevin Gale
Which do you think is more costly: Buying a bit more hardware OR someone making an incorrect business decision due to numbers being wrong? I would never use Float outside of a scientific environment.
adolf garlic
very very thanks to all to support me.
steven spielberg
+1  A: 

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

Paddy
A: 

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.

Dave
A: 

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

Linker3000