Re: Priority Order On Where Clauses
From: Tibor Karaszi (tibor_please.no.email_karaszi_at_hotmail.nomail.com)
Date: 06/23/04
- Next message: sequal: "Re: sql dont start after detach model and msdb"
- Previous message: Tibor Karaszi: "Re: SQL 2000 manual start job sort order"
- In reply to: Ed Fultz: "Priority Order On Where Clauses"
- Next in thread: Uri Dimant: "Re: Migration from SQL7 to SQL2000"
- Messages sorted by: [ date ] [ thread ]
Date: Wed, 23 Jun 2004 15:25:01 +0200
You cannot trust SQL Server to not hit the bad rows. Not even by pushing the filter inside a derived
table. I've been there. Put the stuff in a temp table and work against that.
-- Tibor Karaszi, SQL Server MVP http://www.karaszi.com/sqlserver/default.asp http://www.solidqualitylearning.com/ "Ed Fultz" <efultz@yahoo.com> wrote in message news:O6blHRSWEHA.4056@TK2MSFTNGP11.phx.gbl... > Is there a priority order on a where clause? Or does SQL check all of the > where clause conditions all of the time? I have a case where I can, > sometimes, hit non-numeric data in a column (caused by some bad > conversions). Right now we have the following where clause: > > WHERE convert(integer, ?) BETWEEN convert(integer, low_street_num) AND > convert(integer, high_street_num) > > AND (street_name = ? OR street_alias_name = ?) > > AND city = ? > > AND state_cd = ? > > AND zip_cd LIKE ? > > AND (juris_cd = ? OR juris_cd IS NULL) > > AND (side = ? OR side = 'B') > > AND status_cd = 'A' > > AND (side = ? OR side = 'B') > > AND status_cd = 'A' > > I am wondering if we were to change to put the status_cd = 'A' first would > the query skip all entries whose status_cd is not 'A' and not even try to do > the convert(integer) statement at all? Or is it going to try to do the > convert(integer) regardless and my only solution is to make some routine to > fix the non-numeric data or adjust this sql to ensure the data is numeric > before trying to do the convert? > > > -- > Edward Fultz > Sr. Software Engineer > Pamet Systems > Acton, Ma > www.pametsystems.com > >
- Next message: sequal: "Re: sql dont start after detach model and msdb"
- Previous message: Tibor Karaszi: "Re: SQL 2000 manual start job sort order"
- In reply to: Ed Fultz: "Priority Order On Where Clauses"
- Next in thread: Uri Dimant: "Re: Migration from SQL7 to SQL2000"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|