Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Exclusive Query?

Posted on 2008-10-11
2
Medium Priority
?
220 Views
Last Modified: 2012-05-05
Experts,

Let's say I have a table with 10 fields, and I want to SELECT all of them but one.  Can I do this without listing the 9 I want, but telling SQL I want all fields but the one I don't want?
0
Comment
Question by:NigelRocks
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
2 Comments
 
LVL 93

Accepted Solution

by:
Patrick Matthews earned 1000 total points
ID: 22693743
NigelRocks said:
>>Can I do this without listing the 9 I want, but telling SQL I want all fields but the one I don't want?

No.  You can either use * to say "get all the columns", or you have to specify the columns you want.
There is no other way.
0
 
LVL 60

Assisted Solution

by:Kevin Cross
Kevin Cross earned 1000 total points
ID: 22693754
Not possible in a normal query.  One thought is to use a dynamic query, but much easier just to use some of the tricks to get SQL to populate the columns for you and then delete the one you want.  There are a couple mentioned in the linked article/discussion on this topic below, but here is another trick:

In SQL Management Studio, if you open a table there is a SQL query associated like:
SELECT * FROM TableName

If you click at end of Query and then add an enter or space, and then click on the verify query/syntax button -- SQL Management Studio will change query to be:
SELECT co1, col2, col3, col4, ... FROM TableName

Hope this helps.

http://weblogs.sqlteam.com/jeffs/archive/2007/07/26/60271.aspx
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Backups and Disaster RecoveryIn this post, we’ll look at strategies for backups and disaster recovery.
Viewers will learn how to use the UPDATE and DELETE statements to change or remove existing data from their tables. Make a table: Update a specific column given a specific row using the UPDATE statement: Remove a set of values using the DELETE s…
This lesson discusses how to use a Mainform + Subforms in Microsoft Access to find and enter data for payments on orders. The sample data comes from a custom shop that builds and sells movable storage structures that are delivered to your property. …

604 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