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

What is the default order of an order by clause?

0 Answers  


What is a covered index?

0 Answers  


What is the ‘fillfactor’?

0 Answers  


What are the pros and cons of putting a scalar function in a queries select list or in the where clause?

0 Answers  


Can we drop user if user mapped to any logins

1 Answers  






How are the unique and primary key constraints different?

0 Answers  


How do I start sql server?

0 Answers  


You want to implement the many-to-many relationship while designing tables. How would you do it?

0 Answers  


What is always encrypted?

0 Answers  


Which data types generate inaccurate results if used with an = or <> comparison in a where clause of a sql statement?

0 Answers  


Please get the 4 th maximum salary from a table without using any sql keyword (TOP,MAX are mot allowed)

8 Answers  


What is live lock and deadlock? what is Lock escalation?

2 Answers   Microsoft,


Categories