How to display n-1 columns from n number of columns, from a
single table in MS SQL server 2005?

Answer Posted / rajesh ranjan

Declare @ColumnName varchar(50)
select @ColumnName=Name from syscolumns where id=object_id
(Table_Name) and colid=1 --2 for second Column, 3 for third
exec ('select '+@ColumnName+' from Table_Name')

Is This Answer Correct ?    1 Yes 2 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can the query output be sorted by multiple columns in ms sql server?

744


Explain about analysis services?

773


What is service broker?

779


What do you mean by tablesample?

845


How to use wildcard characters in like operations in ms sql server?

821


Can you explain powershell included in sql server 2008?

680


What is a matrix in ssrs?

119


If you want to send some data from access database to sql server database. What are different component of ssis will you use?

695


Do you know what is lock escalation?

783


Why I am getting this error when renaming a database in ms sql server?

747


Can we write a distributed query and get some data which is located on other server and oracle database?

963


there is a trigger defined for insert operations on a table, in an oltp system. The trigger is written to instantiate a com object and pass the newly inserted rows to it for some custom processing. What do you think of this implementation? Can this be implemented better? : Sql server database administration

675


What are translations and its use? : sql server analysis services, ssas

810


What is buffer cash and log cache in sql server?

811


Is a primary key unique?

714