Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
AskSQLTeam
Ask SQLTeam Question
0 Posts |
Posted - 2004-03-31 : 08:45:51
|
| Anand writes "Hi, Have a question.What is the meaning of a "0=0" clause in a SQL query?In a VB/SQL application, i came across many queries like "select c1,c2..cn from membership where 0=0" & " and c4=23" &....How is the above query different from "select c1,c2..cn from membership where " & " c4=23 " & ....Does adding "0=0" have an impact on the performance of a query?thanksAnand" |
|
|
derrickleggett
Pointy Haired Yak DBA
4184 Posts |
Posted - 2004-03-31 : 09:34:30
|
| I can't see why you would have that. 0=0 all the time. It would be a waste of time to have it in there. It shouldn't have too much affect on performance, except for the fact it will confuse anyone who sees it.MeanOldDBAderrickleggett@hotmail.comWhen life gives you a lemon, fire the DBA. |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-03-31 : 09:34:31
|
| I would guess the query is being built dynamically and the coder didn't want to cope with the where statement on the first clause so put in where 0=0. Then the following clauses all start with and.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
jsmith8858
Dr. Cross Join
7423 Posts |
Posted - 2004-03-31 : 11:10:05
|
| Ah ! good catch, Nigel -- that definitely sounds like it. that is pretty lazy.- Jeff |
 |
|
|
X002548
Not Just a Number
15586 Posts |
Posted - 2004-03-31 : 16:13:18
|
quote: Originally posted by jsmith8858 Ah ! good catch, Nigel -- that definitely sounds like it. that is pretty lazy.- Jeff
I used that once...generating sql from the schemas...By eliminating certain datatypes (text, ntext, image) from columns, I couldn'y always gaurantee that the ordinal_position 1 would always be there...So instead om doing MIN I did it theat way...I then started using WHERE ORDINAL_POSITION = (SELECT MIN(ORDINAL_POSITION)..ectBrett8-) |
 |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2004-04-01 : 02:00:01
|
| You could always change the first and to a where after building the string.==========================================Cursors are useful if you don't know sql.DTS can be used in a similar way.Beer is not cold and it isn't fizzy. |
 |
|
|
|
|
|