I have a webservice method that executes a tabular stored procedure. This sp takes 1 minute to be executed completely. I call that webservice method remotely and get results.
In normal situations everything is OK and I get results successfully.
But when the server is busy the webservice can not execute that sp (I tested it in SQL Profiler and nothing comes to profiler) but I can execute that sp manually in SQL Server Management Studio.
When I restart SQL Server, the problem is solved and the webservice can execute sp.
Why in busy situations webservice can not execute sp but I can do it in SQL Server Management Studio?
How this situation can be explained? How can I solve that?
Execute
sp_whoand see what is happening; my guess is that it is being blocked – perhaps your “isolation level” is different between SSMS and the web-service.Equally, it could well be that the connection’s
SEToptions are different between SSMS and the web-service, which can lead to certain changes in behavior – for example, computed-stored-indexed values are very susceptible toSEToptions: if the caller’s options aren’t compatible with the options that were set when the column was created, then it can be forced to table-scan them, recalculating them all, instead of using the pre-indexed values. This also applies to hoisted xml values.A final consideration is parameter sniffing; if the cache gets generated for
yourproc 'abc'which has very different stats thanyourproc 'def', then it can run very bad query plans. Theoptimize for / unknownhint can help with this.