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

Answers were Sorted based on User's Feedback



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

Answer / k m rajesh

Declare @ColumnName Varchar(50)
Select @ColumnName = Name From syscolumns Where id = object_id(Table_Name) and ColID = (Select Count(name)-1 from SysColumns Where id = object_id(Table_Name))

Is This Answer Correct ?    0 Yes 0 No

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

Answer / 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

More SQL Server Interview Questions

Explain DBCC?

0 Answers   QuestPond,


Explain stored procedure?

0 Answers  


What is shared lock?

0 Answers  


What is hot add cpu in sql server 2008?

0 Answers  


What is an inner join?

0 Answers  


Can truncate be rolled back?

0 Answers  


What are the advantages of using stored procedures in sql server?

0 Answers  


A table contains list of customers and his city with other details. Each customer has a unique number and the table consists millions of data. Query is: I want to retrieve 10 customers from each city, no script, only from single query?

8 Answers   Infosys,


Why the trigger fires multiple times in single login?

0 Answers  


Can you explain important index characteristics?

0 Answers  


Can store procedure call by user define function in SQL server?

10 Answers   HCL,


What is the use of tempdb? What values does it hold?

0 Answers   Abacus,


Categories