SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Return all columns bar some.
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

vtxvtx
Starting Member

18 Posts

Posted - 08/23/2012 :  08:54:57  Show Profile  Reply with Quote
I have a query that generates a table with a different number of columns depending on which parameters I give it.

Now at the end i want to return this table bar 2 columns. Is there a way to do
SELECT * <<but not ...>> FROM Table


Thanks, Andy

sunitabeck
Flowing Fount of Yak Knowledge

5152 Posts

Posted - 08/23/2012 :  09:14:19  Show Profile  Reply with Quote
There is no such feature in T-SQL. Also, using "SELECT *" is considered a bad practice for a variety of reasons.

If the columns to be returned depend on the parameters, you would need to use either conditional logic to select the columns, or use a dynamic SQL query to build the select statement.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
47023 Posts

Posted - 08/23/2012 :  10:08:41  Show Profile  Reply with Quote
quote:
Originally posted by vtxvtx

I have a query that generates a table with a different number of columns depending on which parameters I give it.

Now at the end i want to return this table bar 2 columns. Is there a way to do
SELECT * <<but not ...>> FROM Table


Thanks, Andy


you can do it using dynamic sql but its highly not recommended

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.28 seconds. Powered By: Snitz Forums 2000