Error converting data type numeric to decimal

已答覆 Error converting data type numeric to decimal

  • 2012年5月4日 下午 04:32
     
     

    Hello,

    I have a stored procedure which takes a parameter of type money and sets a column in a table of type decimal(18,12) to that value.  I don't know much about SQL Server data type implicit conversions.  As I understand it, money is defined as decimal (19,4) and the data I'm trying to insert is 0 so I don't see where the problem would occur.

    Thanks.

    edit:  I should add that I'm assuming this column is the one causing the error as it's the only one whose data type as the stored procedure parameter differs from its data type in the table.  Is there any way to be sure what's causing the error?

所有回覆

  • 2012年5月4日 下午 05:25
     
     
    What is the reason of using 18.12? Can you use 18.4 or 18.2 instead? 

    For every expert, there is an equal and opposite expert. - Becker's Law


    My blog


  • 2012年5月15日 上午 06:40
     
     已答覆

    This may have more to do with some sort of data access layer code that you may be using rather than implicit conversion by SQL Server.

    Are you using any sort of helper class that sniffs/creates parameters for you in your application?


    Jason R. Hall MCSE, MCSD, MCPD.NET 2.0

    • 已標示為解答 Ashish Khatri 2012年5月30日 下午 07:46
    •  
  • 2012年5月15日 下午 03:37
     
     

    Hi Ashish,

    You haven't defined what the problem is. Does the SP fail? What error messge does it produce?

    Can you change the stored procedure parameters to match the data types in the table?

    If not can you change the data type in the table to match the source - ie change it to money?

    Seth


    http://lqqsql.wordpress.com

  • 2012年5月30日 下午 07:46
     
     

    This may have more to do with some sort of data access layer code that you may be using rather than implicit conversion by SQL Server.

    Are you using any sort of helper class that sniffs/creates parameters for you in your application?


    Jason R. Hall MCSE, MCSD, MCPD.NET 2.0

    Yes that was the problem.  I was sending a MAXINT to SQL Server due to error on application side, causing the error.