Monday, March 12, 2012

Import Data from Excel with Correct format

Hi,
I have one column of data which is 15.678 but in the excel, i format it to 15.68 ( two decimal place, so in excel i should see 15.68), when i am trying to import the data from excel to sql server by using odbc connection, it still getting 15.678, how can i get the data from 15.678 to 15.68 ( what i see is wat i get).
Thanks for help.

I am stuck at this problem too.

Anyone got a solution to this? Thank you!

|||I have had the same problem before. Some how Excel is funky with that sistuation. The solution I used is I let the SQL Database get the 5 decimal digit number. But if I ever had to use that number in calculation or displaying, I just format the decimal using coding.|||

Try the code in the thread below and use Decimal instead of Money as your data type so you can set precision and scale. Hope this helps.

http://forums.asp.net/1019602/ShowPost.aspx

|||You could also try saving the Excel file as pure CSV (Comma Separated Values) and then import that. As CSV is plain text you can see exactly what you will be getting.|||

Hi,

My main reason to use excel is because they can use excel to do some calculation and then just want to import the final result which the use can determine themselves at the excel and then juz import to the sql server database. So, user just want to export wat they see only and don't want the additional decimal points, have any better idea?

|||You could try putting a trigger on your SQL server table that rounds down the value of the column on insert.|||Sorry, if i set the trigger in the sql server, i need to default a rounding, but now the problem is i am not sure whether the user need to round to 2 decimal points or 3 decimals point or etc...i just want to import as what user already formatted in the excel..that's all...any other idea?

No comments:

Post a Comment