Login or Sign Up to become a member!
LessThanDot Site Logo


Community Wiki

Less Than Dot is a community of passionate IT professionals and enthusiasts dedicated to sharing technical knowledge, experience, and assistance. Inside you will find reference materials, interesting technical discussions, and expert tips and commentary. Once you register for an account you will have immediate access to the forums and all past articles and commentaries.

LTD Social Sitings

Lessthandot twitter Lessthandot Linkedin Lessthandot facebook Lessthandot rss

Note: Watch for social icons on posts by your favorite authors to follow their postings on these and other social sites.


Google Ads

No Functions on Left Side of Operator

From Wiki

Jump to: navigation, search

Don’t use functions on a column in the where clause

You will get an index scan instead of a seek, take a look these two queries. The first query uses a function while the second does not and is therefore sargable

  1. SELECT * FROM Orders WHERE LEFT(CustomerID,1) ='V'
  2. SELECT * FROM Orders WHERE CustomerID LIKE 'V%'

Here is the execution plan

QueryPlan2 0.jpg

Contributed by: --SQLDenis 15:24, 31 May 2008 (GMT)

Part of SQL Server Programming Hacks - 100+ List

Section Query Optimization

110 Rating: 2.5/5 (107 votes cast)