Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations MikeeOK on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How do you do SET DIFFERENCE in SQL code?

Status
Not open for further replies.

christheprogrammer

Programmer
Jul 10, 2000
258
CA
Hi all,
I just need to do a query on a single table, which will result in a particular field being removed. I cannot name all the fields because some may change in the future. i.e. I cannot do this:

SELECT x,y,z,a,b,c,d,f from table1;

I want to do this:

SELECT (* - e) FROM table1;

Obviously this is incorrect syntax, but that's why I am here!
Thanks a bunch

Chris

Chris Grandin
grandin1@yahoo.com
Malaspina has a great computer science program. Top-Notch.
 

Obviously, the syntax you propose is not valid. I'm sure I don't understand the requirement. You either must list columns individually in a select list or select all columns with an "*". Why this particular requirement? Why not name all the columns?

You can dynamically generate SQL statements in a front-end client or in a stored proc. Perhaps you should pass an exclusion parameter to a SP and generate a query list less the excluded column(s). Still struggling to understand why! Terry
------------------------------------
Blessed is the man who, having nothing to say, abstains from giving us worthy evidence of the fact. -George Eliot
 
Thanks for the reply, I have just started using SP's and I don't know the full power yet. How is it possible to generate a dynamic SQL query in a sp? A small example would be great!

Thanks alot
Chris


Chris Grandin
grandin1@yahoo.com
Malaspina has a great computer science program. Top-Notch.
 
One other thing, the reason I cannot include all the names in the SQL Query is that the DB is going to be undergoing big changes, and my routine merges tables, converts dates, etc.. And the SQL cannot be dependent on which fields are present...
Thanks

Chris Grandin
grandin1@yahoo.com
Malaspina has a great computer science program. Top-Notch.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top