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
 SQL Server 2008 Forums
 Transact-SQL (2008)
 SELECT * FROM view except one column

Author  Topic 

simondeutsch
Aged Yak Warrior

547 Posts

Posted - 2011-12-07 : 11:20:44
What is the simplest way to select all columns from a view, except one column which needs a CASE statement but needs to be aliased to the same name as the column name? Is there a way to do this without listing all the column names?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2011-12-07 : 11:35:24
no way other than listing all the individual columns

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

Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2011-12-08 : 03:43:12
You can do something like this and use the result

select case when column_name='name' then 'case when column_name=''name'' then ''yes'' else ''no'' end ' else column_name end+',' as column_name from information_schema.columns
where table_name='spt_values'

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -