Sort operator in Execution plan

VINOD 2015-04-21 10:42:45

i am just executing a query and i am getting sort operator in sql.
Can someone plz help me how to remove it and where i can all information regarding these icons and how to resolve them.

SQLkiwi 2015-04-21 10:51:45
For that particular query, to avoid the sort you would need an index like:

CREATE INDEX i 
ON dbo.CompanyRespEntityUser
    (CompanyID, GroupUserCode);

You can also increase the efficiency a little by using the SARGable LIKE instead of SUBSTRING:

SELECT 
    SUBSTRING(CREU.GroupUserCode,2,15) AS iUserID  
FROM dbo.CompanyRespEntityUser AS CREU
WHERE 
    CREU.GroupUserCode LIKE 'U%'
    AND CREU.CompanyID = 65  
GROUP BY 
    CREU.GroupUserCode;