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.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 Return all columns bar some.

Author  Topic 

vtxvtx
Starting Member

18 Posts

Posted - 2012-08-23 : 08:54:57
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
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-08-23 : 09:14:19
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

52326 Posts

Posted - 2012-08-23 : 10:08:41
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
   

- Advertisement -