I came to the conclusion that, as in the following cases, search / scan. But I didn’t get why it scans in the first case and searches in the second case. I understood the third case.
SELECT c.contactname FROM Sales.Customers c WHERE c.contactname LIKE '%a'-- Does a Scan 1st Case SELECT c.contactname FROM Sales.Customers c WHERE c.contactname LIKE 'a%'-- Does a Seek 2nd Case SELECT c.contactname FROM Sales.Customers c WHERE c.contactname LIKE '%a%'-- Does a Scan
If I create an index in the name of the contact that has an example of data below, how will the index tree .. like us, if we build for numbers, then it will compare less than more, and it will move along how the index tree will go in case below.
c.contactname mark anna krishna nadejda allen bob cab
, : . . () , , .
:
/nadejda mark / \krishna cab \ /bob anna \allen
, a% , , . , C > A, . %a . , , node A. .
a%
%a
, , SQL Server. , .
. contactname - . (, , , , B-, ).
contactname
contactname like 'a%', , , "a". , , , . SQL Server like ( ).
contactname like 'a%'
like
contactname like '%a', : " , " a ". , , "a". . , "a" "a". , "z" "a". , .
contactname like '%a'
, , , . , .
allen anna bob cab krishna mark nadejda
, LIKE 'a%' Sql-, , , "" . , LIKE '%A', , -, A.
LIKE 'a%'
LIKE '%A'
, .