Use of OPTIMIZE FOR
OPTIMIZE FOR a little known but powerful SQL Server feature.
SET @ProdCode = N’100’
SELECT ProdId,MfnDate
FROM Product
WHERE ProdCode = @ProdCode
OPTION (OPTIMIZE FOR (@ ProdCode = N’100’))
The OPTIMIZE FOR hint will force an index seek when the specific value is provided.
More about OPTIMIZE FOR/OPTIMIZE FOR UNKNOWN here
0 comments:
Post a Comment