
SQL DBA Tools: Troubleshooting SQL Server Windows Permissions with xp_logininfo
May 22, 2026

Parameter sniffing occurs when SQL Server creates an execution plan based on the specific parameters used during the first compilation of a stored procedure — causing severe degradation when other parameters require a different strategy.
Parameter sniffing occurs when SQL Server creates an execution plan based on the specific parameters used during the first compilation of a stored procedure. While this initial plan optimizes performance for that specific parameter value, it can cause severe performance degradation when other parameters require a different data distribution retrieval strategy.
You can identify parameter sniffing by observing a stored procedure that usually runs instantly but suddenly takes minutes to execute without any changes to the underlying database code.
-- Force recompile on a specific query
SELECT * FROM Orders WHERE CustomerID = @CustomerID
OPTION (RECOMPILE)-- Optimize for a known typical value
SELECT * FROM Orders WHERE CustomerID = @CustomerID
OPTION (OPTIMIZE FOR (@CustomerID = 'ALFKI'))
-- Or use statistical averages
SELECT * FROM Orders WHERE CustomerID = @CustomerID
OPTION (OPTIMIZE FOR (@CustomerID UNKNOWN))CREATE PROCEDURE GetOrders @CustomerID nvarchar(10)
AS
BEGIN
DECLARE @LocalCustomerID nvarchar(10) = @CustomerID
SELECT * FROM Orders WHERE CustomerID = @LocalCustomerID
END-- Update statistics for a specific table
UPDATE STATISTICS dbo.Orders WITH FULLSCAN
-- Or update all statistics in the database
EXEC sp_updatestatsNeed help tuning SQL Server performance? Datazip provides 24/7 managed monitoring and expert DBA support. Call 1-833-DATAZIP or visit www.SQLBrainBox.com for our monitoring tool.
Datazip provides 24/7 managed backup monitoring, encryption, and Azure Recovery Vault setup. US-based engineers, fluent in T-SQL.