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 |
|
Billkamm
Posting Yak Master
124 Posts |
Posted - 2006-02-16 : 16:21:59
|
| I need to return a table that contains no results (0 rows)I tried doing SELECT NULL; but that returned 1 row, because NULL is in a row.I was going to do something like SELECT NULL FROM table WHERE 1 = 2;But I'm sure there has to be a better way. |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2006-02-16 : 16:23:14
|
| WHERE 1=2 is the best way.Tara Kizeraka tduggan |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-02-17 : 08:26:36
|
| Also you dont need to use Null. It can be numbers alsoSELECT 1 FROM table WHERE 1 = 2MadhivananFailing to plan is Planning to fail |
 |
|
|
dsdeming
479 Posts |
Posted - 2006-02-17 : 10:20:39
|
| If you want to return an empty recordset with the same structure as your table, don't use SELECT 1 FROM table WHERE 1 = 2. It returns a recordset with 1 unnamed column. Instead use SELECT * FROM table WHERE 1 = 2.Dennis |
 |
|
|
|
|
|