Speaking in Code

Wednesday, May 27, 2009

Parameter Sniffing Gone Bad

In rare instances, SQL Server's parameter sniffing behavior can result in dramatically poor performance.

The test is simple.

If your stored procedure takes an inordinate amount of time to run, but an equivalent query can runs much faster with local variables in place of the stored procedure parameters, then you may have a case of parameter sniffing gone bad.

Adding the local variable layer between your parameters and the interior of your proc is a good workaround to this problem.

It's possible too that the proc is overly complex if this occurs.

Linked Server between 2005 64 bit and 2000 32 bit

If you are having problems with linked servers between 64 and 32 bit sql instances, check this out:
http://support.microsoft.com/kb/906954

The errors I've fixed with this are obtuse and don't seem related to the fix.
Running instcat.sql from the command line is a solution I've found productive.

osql -E -S -i \instcat.sql