0

I have the value as 2800320 which I need to insert to table for numeric(9, 4) datatype. In the code I have given as float.Parse(record.Substring(i, 8)).When I insert to sql arithmetic overflow error occurs. Pls tell how to correct this?

  • Is that a date, with a typo? Just curious with today being 28-03-20 and all.. – Caius Jard Mar 28 '20 at 05:55
  • No..Its not date :) – Anjana Jain Mar 28 '20 at 05:58
  • Can you share the code which inserts the data in table along with sample values? Which type of database it is? Ms SQL or my SQL? – Chetan Mar 28 '20 at 05:58
  • Numeric(9,4) can not store 7 digit number coz it can accommodate only number with 5 digit before decimal point and 4 digits after decimal point. https://stackoverflow.com/questions/60897745/how-to-correct-arithmetic-overflow-error-converting-nvarchar-to-numeric-for-sql – Chetan Mar 28 '20 at 06:04

1 Answers1

1

NUMERIC(9,4) means "a number with 9 digits in total, 4 of which are after a decimal point" meaning you have 5 digits left over to store your 7 digit number 2800320

Clearly, this isn't going to work. Pick a bigger numeric, or divide your number by 100 or more so it will fit

Caius Jard
  • 72,509
  • 5
  • 49
  • 80