declare @name varchar(156)
set @name ='sara'
--Query 1:
SELECT [PNAME] FROM [tbltest] where [PNAME] like '%'+@name+'%'
--Query 2:
SELECT [PNAME] FROM [tbltest] where [PNAME] like '%sara%'
suppose that there is a NoneClustered Index on [PNAME] column of [tbltest]. when running Queries, Excution plan show index Seek For Query 1 and Index Scan for Query 2. i expected that Excution Paln Show Index Scan For both queries,but because of using parameter in the first Query,it Show Index Seek. So what i the mater? in both query we used '%' at oth side,and know that in this state ,sql does not consider index but why in first Query Excution Plan Show Index Seek? thanks