2

Morning,

I am new to this so just need a quick hand on how to create a schema.ini file.

I need to have 2 cols, one for the product sku, which is a string value. And one for the price, which is a decimal value.

I currently have the following in my schema.ini, but i am unsure how what they should be, i have done the sku as Text, but unsure about the decimal one.

[test.csv]
ColNameHeader=False
Format=CSVDelimited
DateTimeFormat=dd-MMM-yyyy
Col1=sku Text
Col2=amzPrice 
thatuxguy
  • 2,418
  • 7
  • 30
  • 51
  • 1
    Are you using ODBC, or JET, or something else? The allowable data types are different for each apparently: http://msdn.microsoft.com/en-us/library/windows/desktop/ms709353(v=vs.85).aspx – RB. Aug 29 '12 at 08:49
  • I am using Microsoft.Jet.OLEDB as per this article... http://vikashbhorale.blogspot.co.uk/2012/02/uploading-and-importing-csv-file-to-sql.html - thanks you post looks pretty interesting – thatuxguy Aug 29 '12 at 09:04
  • @RB. thanks for your link, it worked a treat i used Double :D Put it as the answer and i will mark it for you :) – thatuxguy Aug 29 '12 at 09:18
  • 1
    I've posted an answer, and noted that Double is probably not the best datatype as that is a floating-point number, so is subject to the usual rounding issues. Currency is a decimal number, and is probably more appropriate for you :) – RB. Aug 29 '12 at 09:26

1 Answers1

2

As you are using JET I would suggest the most appropriate datatype is Currency. This is an 8-byte decimal value, with a range -922,337,203,685,477.5808 to 922,337,203,685,477.5807. I would discourage the use of Double for storing decimal numbers, as it is imprecise. See this SO question for example.

If you only have to have a resolution of pence/cent, then you can store your currency values as an integer datatype (e.g. Long) and treat them as pence, not pounds. This ensures you never have to worry about rounding errors, but you cannot have fractions of a pence.

Microsoft maintain a list of supported datatypes is here. You can find definitions for the JET datatypes here.

Community
  • 1
  • 1
RB.
  • 36,301
  • 12
  • 91
  • 131