sql solace

Monday, 14 April 2014

SQL Development : Conditional WHERE clauses

If you need to do conditional WHERE clauses, adopt BOOLEAN logic for doing so.
Although CASE statements are more readable, BOOLEAN statements will be evaluated faster.

Further Reading -
  • Kevin Attard - Conditional Filtering: Using conditions in T-SQL WHERE clauses 
  • Jeff Smith - SQL WHERE clauses: Avoid CASE, use Boolean logic 
  • Jeff Smith - Optimizing Conditional WHERE Clauses: Avoiding ORs and CASE Expressions  
  • Code Project - Implementing Dynamic WHERE-Clause in Static SQL 
  • Split a string to a table using T-SQL

By r5d4 - April 14, 2014
Email ThisBlogThis!Share to XShare to FacebookShare to Pinterest

No comments:

Post a Comment

Newer Post Older Post Home
Subscribe to: Post Comments (Atom)

Pages

  • Crisis TSQL
  • Home
  • Dba 101
  • Dev 101
  • Indexes
  • SSIS
  • SSRS
  • Resources
  • Calculators
  • SSMS
  • Community Contributions
  • Free Stuff

Blog Archive

  • ►  2020 (1)
    • ►  March (1)
  • ►  2019 (3)
    • ►  October (1)
    • ►  March (1)
    • ►  January (1)
  • ►  2018 (18)
    • ►  December (1)
    • ►  August (1)
    • ►  July (7)
    • ►  June (3)
    • ►  May (2)
    • ►  April (1)
    • ►  March (1)
    • ►  February (1)
    • ►  January (1)
  • ►  2017 (9)
    • ►  December (2)
    • ►  November (1)
    • ►  August (1)
    • ►  June (1)
    • ►  May (2)
    • ►  April (1)
    • ►  March (1)
  • ►  2016 (5)
    • ►  November (1)
    • ►  August (1)
    • ►  July (1)
    • ►  June (1)
    • ►  January (1)
  • ►  2015 (7)
    • ►  May (3)
    • ►  February (1)
    • ►  January (3)
  • ▼  2014 (30)
    • ►  October (5)
    • ►  September (4)
    • ►  August (2)
    • ►  July (3)
    • ►  June (2)
    • ►  May (4)
    • ▼  April (4)
      • SQL Development : Query Tips
      • SQL Development : Conditional WHERE clauses
      • SQL Development : Implicit Conversions
      • SQL Development : Sargability
    • ►  March (3)
    • ►  January (3)
  • ►  2013 (47)
    • ►  July (2)
    • ►  May (1)
    • ►  April (3)
    • ►  March (5)
    • ►  February (7)
    • ►  January (29)
  • ►  2012 (24)
    • ►  December (1)
    • ►  September (3)
    • ►  August (2)
    • ►  June (1)
    • ►  April (1)
    • ►  March (4)
    • ►  February (7)
    • ►  January (5)
  • ►  2011 (100)
    • ►  December (4)
    • ►  November (6)
    • ►  October (8)
    • ►  September (5)
    • ►  August (9)
    • ►  July (9)
    • ►  June (10)
    • ►  May (10)
    • ►  April (15)
    • ►  March (11)
    • ►  February (6)
    • ►  January (7)
  • ►  2010 (175)
    • ►  December (8)
    • ►  November (10)
    • ►  October (12)
    • ►  September (12)
    • ►  August (6)
    • ►  July (20)
    • ►  June (15)
    • ►  May (16)
    • ►  April (24)
    • ►  March (23)
    • ►  February (16)
    • ►  January (13)
  • ►  2009 (236)
    • ►  December (12)
    • ►  November (16)
    • ►  October (22)
    • ►  September (19)
    • ►  August (29)
    • ►  July (26)
    • ►  June (21)
    • ►  May (22)
    • ►  April (16)
    • ►  March (21)
    • ►  February (11)
    • ►  January (21)
  • ►  2008 (178)
    • ►  December (19)
    • ►  November (21)
    • ►  October (20)
    • ►  September (17)
    • ►  August (24)
    • ►  July (13)
    • ►  June (12)
    • ►  May (15)
    • ►  April (10)
    • ►  March (8)
    • ►  February (8)
    • ►  January (11)
  • ►  2007 (108)
    • ►  December (7)
    • ►  November (10)
    • ►  October (8)
    • ►  September (4)
    • ►  August (9)
    • ►  July (7)
    • ►  June (8)
    • ►  May (15)
    • ►  April (12)
    • ►  March (8)
    • ►  February (8)
    • ►  January (12)
  • ►  2006 (102)
    • ►  December (10)
    • ►  November (11)
    • ►  October (10)
    • ►  September (11)
    • ►  August (12)
    • ►  July (8)
    • ►  June (12)
    • ►  May (16)
    • ►  April (11)
    • ►  March (1)

Search This Blog

Recommended Blogs

UK SQL Server

Chris Webb
Dave Ballantyne
Jen Stirrup
John Sansom
Mark Broadbent
Richard Douglas
Simon Sabin
Tony Rogerson

Worldwide SQL Server
Aaron Bertrand
Brent Ozar
Buck Woody
Conor Cunningham
Grant Fritchey
Linchi Shea
Jonathan Kehayias
Paul Randal
Paul White
Vinay Thakur


Report Abuse

View Richard Doering's profile on LinkedIn

Labels

  • 101 (8)
  • active directory (10)
  • admin (2)
  • Agile / Scrum (2)
  • annoyances (2)
  • asp (1)
  • backups (11)
  • BI (4)
  • blocking (2)
  • blogging (5)
  • bookmark (184)
  • caching (1)
  • career (26)
  • cdc (2)
  • clr (5)
  • code (2)
  • collation (1)
  • community (2)
  • compatibility (1)
  • compression (14)
  • configuration (11)
  • connectivity (2)
  • constraints (6)
  • crosstab (2)
  • datawarehouse (2)
  • datetime (7)
  • design (2)
  • diagramming (2)
  • dmv (10)
  • dynamic sql (1)
  • email (8)
  • event forwarding (1)
  • excel (1)
  • function (2)
  • group policy (9)
  • hyper-v (20)
  • iis (2)
  • indexes (27)
  • jdbc (2)
  • linked servers (8)
  • mac (1)
  • memory (1)
  • mysql (2)
  • networking (15)
  • news (1)
  • nulls (2)
  • ole (4)
  • opendatasource (1)
  • openrowset (2)
  • partitioning (4)
  • pbm (3)
  • performance (42)
  • permissions (12)
  • pivot (2)
  • powershell (1)
  • recovery mode (2)
  • replication (3)
  • reporting services (4)
  • resource governor (2)
  • restore (4)
  • schema (3)
  • schemas (1)
  • scripts (7)
  • searching (7)
  • security (30)
  • service broker (7)
  • shrink (3)
  • sql 2000 (2)
  • sql 2005 (14)
  • sql 2008 (60)
  • sql 2008 r2 (2)
  • sql 2011 (1)
  • sql 2012 (1)
  • sql agent (8)
  • sqlbits (4)
  • sqlservercentral (6)
  • ssc (1)
  • ssis (46)
  • ssrs (5)
  • storage (1)
  • synonyms (1)
  • sysadmin (16)
  • system objects (8)
  • systems (40)
  • table compression (3)
  • tds (1)
  • testing (2)
  • tools (16)
  • tsql (148)
  • vba (1)
  • video (1)
  • video notes (2)
  • view (1)
  • virtual pc 2007 (1)
  • virtualbox (4)
  • vista (8)
  • web (1)
  • windows 2000 (1)
  • windows 2008 (36)
  • windows 2008 R2 (1)
  • Windows 7 (7)
  • wsus (3)
  • xml (6)
  • xp (3)

Recommended Blogs

UK SQL Server

Chris Webb
Dave Ballantyne
Jen Stirrup
John Sansom
Mark Broadbent
Richard Douglas
Simon Sabin
Tony Rogerson

Worldwide SQL Server
Aaron Bertrand
Brent Ozar
Buck Woody
Conor Cunningham
Grant Fritchey
Linchi Shea
Jonathan Kehayias
Paul Randal
Paul White
Vinay Thakur


View Richard Doering's profile on LinkedIn

Subscribe To

Posts
Atom
Posts
Comments
Atom
Comments
Powered by Blogger.