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

Define union, union all, minus, intersect?

0 Answers  


Where are sql server user names and passwords stored in sql server?

0 Answers  


what is cursor?why we will go to cursor?advantages &disadvantages of cursors?

1 Answers  


Where do we generally create INDEX?

1 Answers   Ernst Young, Thomson Reuters,


How to get the definition of a user defined function back?

0 Answers  






What is 1nf normalization form?

0 Answers  


What is the significance of null value and why should we avoid permitting null values?

0 Answers  


what is maximum size of temp db?

4 Answers   iSoft,


How to create a simple user defined function in ms sql server?

0 Answers  


What are the acid properties?

0 Answers  


How does a profiler work?

0 Answers  


What is @@error in sql?

0 Answers  


Categories