I have a data access layer which returns DataSets/DataTables by executing Stored Procedure. Everything was working fine from many months. But suddenly we have started getting the following error.

System.ArgumentException; Column < ColumnName > does not belong to table < TableName >

I wrote come extra logging code to troubleshoot this issue. I was shocked to see that the SP sometimes returns Unexpected result set. The Stored Procedure sometimes returns result that are requested by a Windows Services using some other Stored Procedure.

I monitored the Sql Server traffic using a Profiler. When this error occured Sql Profiler didn't show any execution for the SP that I actually executed. Its difficult to reproduce this bug it happens randomly.

We have only faced this problem in our testing environment. Our testing environment is running Windows 2003 Server & Sql Server 2005 Express Edition.

In past we have run several rigorous load test on our application using both Sql Server 2005 Express and Standard Edition but we have never faced this issues.

Has anybody faced such problem before?


If SQL Profiler isn't showing your procedure being executed then it isn't. Something in the application code is changing the stored procedure which is being called.

I've never seen (or heard of) SQL Server running a different stored procedure. It wouldn't be able to as the parameters would all be different.

  • I am not blaming Sql Server .. all I saw was my code returning a different result set. I you want to see some code .. I would b glad to post – Zuhaib Oct 9 '09 at 6:08
  • You might want to post the code in a question over of Stack Overflow. They are much better at reading code that most people here (myself included). – mrdenny Oct 9 '09 at 18:02

Are you using nHibernate or some ORM framework by chance? We saw some changes to the code being called, additions to just the stored proc, in some testing. The stored proc was still being called, if I remember, but we saw strange code in Profiler.

Can you post some samples of what the Profiler returned? I'm also confused by what you mean when you say "requested by windows services"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy