1

I am getting an exception from Dapper Bulk Copy Looks like the underlying bulk copy operation is failing. I dumped the data in json and found the value creating problem is 259815703.3430760631

StackTrace:
at System.Data.SqlClient.SqlBulkCopy.ConvertValue(Object value, _SqlMetaData metadata, Boolean isNull, Boolean& isSqlType, Boolean& coercedToDataFeed)
.....
Inner Exception 1:
InvalidOperationException: The given value of type Decimal from the data source 
cannot be converted to type decimal of the specified target column.

 Inner Exception 2:
 ArgumentException: Parameter value '259815703.34307606' is out of range

The table has decimal(18,6) and instead of storing with lower precision the API is throwing.

I tried the following and it works, the value that is stored is 6 decimal instead of 10 as expected

CREATE TABLE #t1(c1 DECIMAL(18,6))
INSERT INTO #t1(c1) values(259815703.3430760631)
Anand
  • 1,387
  • 2
  • 26
  • 48
  • Are ANSI_WARNINGS on or off in your session? – Alex Sep 17 '19 at 13:07
  • Hi Alex, Thanks for looking into my question ANSI_WARNINGS is ON for the DB. I solved the issue with decimal.Round to 6 places of decimal – Anand Sep 20 '19 at 18:12

1 Answers1

1

I solved the issue with decimal.Round to 6 places of decimal

Anand
  • 1,387
  • 2
  • 26
  • 48