Database Reference
In-Depth Information
Listing 2-10. SARG predicates and data types: Selected with integer parameter
declare
@IntParam int = '200'
select * from dbo.Data where VarcharKey = @IntParam
select * from dbo.Data where VarcharKey = convert(varchar(10),@IntParam)
As you see in Figure 2-14 , in the case of the integer parameter, SQL Server scans the clustered index converting
the varchar to an integer for every row. In the second case, SQL Server converts the integer parameter to a varchar at
the beginning, and utilizes a much more efficient clustered index seek operation.
Figure 2-14. SARG predicates and data types: Execution plans with integer parameter
 
Search WWH ::




Custom Search