Re: WHERE 1=2 with performance nightmares
- From: Ralf Jansen <ralf.jansen_nospam@xxxxxxxxxxxxxx>
- Date: Wed, 01 Aug 2007 21:19:23 +0200
Sarah schrieb:
Recently we started seeing this "WHERE 1=2" in sql profiler trace that even makes a lot of our sql statements invalid when there is *already* a WHERE clause in our sql.I don't know why you get a second WHERE clause. Do you really get the WHERE keyword twice?
Here is an example copied from a trace file:
SET FMTONLY ON SELECT Col1,Col2 from Table1 WHERE Col1 = 8 and Col2 = 6
WHERE 1=2 SET FMTONLY OFF
SET FMTONLY queries on SQL Server are normal.
They are used by the OLEDB Provider to retrieve Parameter information and they return no result set. The Provider normally changes the Statement in a way so that it only returns the parameter columns and that the WHERE will always evaluates to false because an actual result set isn't needed. But i have never seen that it generates invalid SQL.
Your SQL looks like you are not using parameters. If so you should set Paramcheck = false for you ADOQuery/ADODataset. The dataset won't check for parameters then and this will prevent the provider from generating the SET FMTONLY query at all.
--
Ralf Jansen
deepinvent Software GmbH - Viersen, Germany - http://www.deepinvent.com
Archiving E-mails with MailStore: http://www.mailstore.com
.
- Follow-Ups:
- Re: WHERE 1=2 with performance nightmares
- From: Sarah
- Re: WHERE 1=2 with performance nightmares
- References:
- WHERE 1=2 with performance nightmares
- From: Sarah
- WHERE 1=2 with performance nightmares
- Prev by Date: Re: Vista and Delphi 5
- Next by Date: Re: Extremely long build times
- Previous by thread: WHERE 1=2 with performance nightmares
- Next by thread: Re: WHERE 1=2 with performance nightmares
- Index(es):
Relevant Pages
|