Also i have used in a query which dynamically builds another actual query
to run; in my example i was using it to build the join clause of which the
number of join fields would be variable. Rather than case the first join
with an "ON" and subsequent joins with an "AND", i used "ON 1=1" for the
first part of my join.
But if you think that is mad, some of the stuff i've been looking at has
had coded in t-sql "WHERE 1=0"...........
go figure ! ;)
rgds
"Carter Phillip "
<mssqldba-ezmlmshield-x37010695.[Email address protected] To: "LazyDBA Discussion"
om> <[Email address protected]
cc:
Subject: RE: Query Question
Thursday August 26, 2004 08:06
I've seen this done in a couple of web applications where they pass
through the field name and criteria to a stored procedure. If they want
everything back they just pass '1' as the field name and 1 as the
criteria.
By calling the same stored procedure with different parameters they get
back different results.
EG: Exec FindCustomers 'lastname', 'smith'
Results in a query like,
Select * from customers
Where lastname = 'smith'
Thanks
Phillip Carter
Ph: +61 3 9235 1691
-----Original Message-----
From: prakash
[mailto:mssqldba-ezmlmshield-x55741692.[Email address protected]
Sent: Thursday, 26 August 2004 4:40 PM
To: LazyDBA Discussion
Subject: Query Question
Hi All,
Why some people always use 1 =1 in there query. Any reasons behind
this....
Example
Select * from [Table name]
Where 1 =1
Thanks
Prakash Zalkikar
SQL DBA
WebDirekt India Pvt LTD
C 1/19 Kumar City, Kalyani Nagar
Pune - 411014
Phone(O):- 91-20-27031240
Phone(R):- 91-20-27034557
Mobile:- 9422314041
mailto:- p.[Email address protected]
---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY Website :
http://www.LazyDBA.com To unsubscribe:
http://www.lazydba.com/unsubscribe.html
For additional commands, e-mail: mssqldba-[Email address protected]
IMPORTANT DISCLAIMER - THIS MAY AFFECT YOUR LEGAL RIGHTS:
Because this document has been prepared without consideration of any
specific clients investment objectives, financial situation or needs,
a Bell Potter Securities Limited investment adviser should be
consulted before any investment decision is made.
While this document is based on the information from sources which
are considered reliable, Bell Potter Securities Limited, its directors,
employees and consultants do not represent, warrant or guarantee,
expressly or impliedly, that the information contained in this document
is complete or accurate.
Nor does Bell Potter Securities Limited accept any responsibility to
inform you of any matter that subsequently comes to its notice, which
may affect any of the information contained in this document.
This document is a private communication to clients and is not intended
for public circulation or for the use of any third party, without the
prior approval of Bell Potter Securities.
Disclosure of Interest: Bell Potter Securities Limited receives commission
from dealing in securities and its authorised representatives, or
introducers
of business, may directly share in this commission. Bell Potter Securities
and its associates may hold shares in the companies recommended.
Bell Potter Securities Limited ABN 25 006 390 772 AFS Licence No. 243480
---------------------------------------------------------------------
TO REPLY TO EVERBODY , PLEASE CLICK REPLY-ALL, NOT JUST REPLY
Website : http://www.LazyDBA.com
To unsubscribe: http://www.lazydba.com/unsubscribe.html
For additional commands, e-mail: mssqldba-[Email address protected]
MS Sql Server LazyDBA home page