Solved

Is there a way to Select none in SQL?

Posted on 2009-05-04
4
2,385 Views
Last Modified: 2012-05-06
Hello,

I know * selects all, so is there a similar way to SELECT none in SQL?

Thanks in advance,


0
Comment
Question by:dschrishuhn
4 Comments
 
LVL 51

Accepted Solution

by:
Mark Wills earned 100 total points
ID: 24295896
Interesting question....

You can select <column list> from <datasource> where 1 = 2

which will give you all the <column list> but with NULL entires.

Is that what you mean ?

You can also :

select NULL from <datasource>

but in Access think it is the same as if nothing was selected - but is handy in SQL Server to test "if exists" type conditions.
0
 
LVL 6

Assisted Solution

by:mvgeertruyen
mvgeertruyen earned 75 total points
ID: 24295903
* selects all columns... Why would you want to run a query that doesn't return columns?
If you just want to return no rows you can do that with select top 0 *
0
 
LVL 7

Assisted Solution

by:coffeeshop
coffeeshop earned 75 total points
ID: 24296004
Or

SELECT 1 AS Dummy FROM <table>

to get all rows but no useful information about it.
0
 

Author Closing Comment

by:dschrishuhn
ID: 31577572
Found a workaround.  Thanks for your time and suggestions
0

Featured Post

3 Use Cases for Connected Systems

Our Dev teams are like yours. They’re continually cranking out code for new features/bugs fixes, testing, deploying, testing some more, responding to production monitoring events and more. It’s complex. So, we thought you’d like to see what’s working for us.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

If you have heard of RFC822 date formats, they can be quite a challenge in SQL Server. RFC822 is an Internet standard format for email message headers, including all dates within those headers. The RFC822 protocols are available in detail at:   ht…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
This Micro Tutorial hows how you can integrate  Mac OSX to a Windows Active Directory Domain. Apple has made it easy to allow users to bind their macs to a windows domain with relative ease. The following video show how to bind OSX Mavericks to …
Two types of users will appreciate AOMEI Backupper Pro: 1 - Those with PCIe drives (and haven't found cloning software that works on them). 2 - Those who want a fast clone of their boot drive (no re-boots needed) and it can clone your drive wh…

770 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question