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 |
yonabout
Posting Yak Master
112 Posts |
Posted - 2010-10-07 : 05:16:21
|
I'm debugging an old stored procedure, and there's a section in it that goes something like this:select a, b, c into #totalsfrom ajoin b on a.a = b.awhere 0=1 what does the "Where 0 = 1" bit do?I've also seen other selection criteria with "Where 1=1" after it.I'm assuming that "Where 0 = 1" equates to false, and "Where 1=1" equates to true, but if that's right, what is true or false?Cheers,Yonabout |
|
harsh_athalye
Master Smack Fu Yak Hacker
5581 Posts |
Posted - 2010-10-07 : 05:19:04
|
It is a simple trick to create an empty temp table with same number of columns and format as in the select query.Harsh Athalyehttp://www.letsgeek.net/ |
|
|
Transact Charlie
Master Smack Fu Yak Hacker
3451 Posts |
Posted - 2010-10-07 : 05:44:21
|
other tricks for the same things are SELECT TOP 0 x, y, z INTO foo FROM....Charlie===============================================================Msg 3903, Level 16, State 1, Line 1736The ROLLBACK TRANSACTION request has no corresponding BEGIN TRANSACTION |
|
|
yonabout
Posting Yak Master
112 Posts |
Posted - 2010-10-07 : 06:03:55
|
OK, Thanks.Is "Where 1=1" used to do the same thing?Cheers,Yonabout |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-10-07 : 06:06:41
|
quote: Originally posted by yonabout OK, Thanks.Is "Where 1=1" used to do the same thing?Cheers,Yonabout
Where 1 = 0 will create the other table with same structure (not index or pk) and the table will be emptyWhere 1 = 1 will create the other table with same structure (not index or pk) and the table will also have data of base table.Regards,BohraI am here to learn from Masters and help new bees in learning. |
|
|
yonabout
Posting Yak Master
112 Posts |
Posted - 2010-10-07 : 06:27:40
|
Cool.Thanks for your helpCheers,Yonabout |
|
|
pk_bohra
Master Smack Fu Yak Hacker
1182 Posts |
Posted - 2010-10-07 : 06:58:36
|
quote: Originally posted by yonabout Cool.Thanks for your helpCheers,Yonabout
You are welcome I am here to learn from Masters and help new bees in learning. |
|
|
|
|
|
|
|