I’m working with sql server 2008r2 developer. I have a stored procedure that adds a row to a db table that I call from .NET/ C# code. It’s passed about 70 parameters (all field values). This executes about 5,000 times daily, for months, with no problem until recently. The table is of fundamental stock market data, with each symbol getting its own row every day. For one particular stock symbol, I’m getting the sql error:
Error converting data type numeric to decimal
I just manually added a row to the table, and entered column by column each parameter value being passed via the stored procedure, with no error. I checked and rechecked the stored procedure for correct pairing of parameter/ column in the insert statement, also ok.
So my question… is there a way to find the specific erroneous parameter (or other error source if I’m barking up the wrong tree) using profiler? At the moment I only know how to view all the parameter values prior to the sp execution… but I can do this on the .NET side already.
From the error we can understand it is a data type problem. Since there are many fields, it will be difficult to find the erroneous parameter.
Once I have faced a similar issue, I will explain my approch. This may help you.
You can try with a parameter array. Insted of passing seperate parameters you can concat all field name & value with a coma.
for example ‘field1name:field1value,field2ame:field2value,….’
and in the procedure first split the text with ‘,’. again split the value with ‘:’. So you will get field name and value.
Now in a loop you can update each field one by one. and check where it throwing error.
You can check this fnSplit function, and modify it to store both Field and its value. Then the function will return a table with all Fields and values
So you can loop with this table and try your update one by one.