none
SQLBulkCopy Max Decimal Issue RRS feed

  • Question

  • I'd like to be able to move decimals from an outside data source to SQL Server using SQLBulkCopy with the datareader option.  

    The issue is that when the decimal is over the decimal max value in .NET it throws an error.  I'm assuming the case is the same with decimal min value.  

    BigDecimal in Hadoop would probably also cause issues.  

    The work around right now which we are trying to implement is to cast the column as character data and then when it is loaded alter the column data type on the SQL Server side.

    So I'm thinking that Decimal Max and Min value in the .NET Framework should be updated to reflect the larger data types coming from the newer databases including SQL Server.  Thank you.


    • Edited by ToadRW Friday, November 21, 2014 10:49 PM
    • Moved by Bob Beauchemin Saturday, November 22, 2014 12:15 AM Moved to the forum for client-side SqlClient questions
    Friday, November 21, 2014 10:48 PM

Answers

  • Hello ToadRW,

    >> So I'm thinking that Decimal Max and Min value in the .NET Framework should be updated to reflect the larger data types coming from the newer databases including SQL Server.

    Thanks for your feedback, as far as I know, this is a designed feature, the SQL Server decimal, at maximum precision, covers the range from -1038+1 to 1038-1. In .NET, however, it can cover anywhere from ±10−28 to ±7.9×1028, depending on the number, it treats decimals very similar to floats—it stores it as a pair of numbers, a mantissa and an exponent.

    Usually, when designing a decimal column, we would consider its mapped type in .NET Framework. And if you have an exceed decimal column, the workaround you use current should be ok.

    And if you want the team know this feedback, you could post voice to the below site and vote it:

    http://visualstudio.uservoice.com/forums/121579-visual-studio

    Regards.


    We are trying to better understand customer views on social support experience, so your participation in this interview project would be greatly appreciated if you have time. Thanks for helping make community forums a great place.
    Click HERE to participate the survey.

    Monday, November 24, 2014 2:10 AM
    Moderator