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

Describe about first three Normal forms.

1 Answers   HP,


Following are some of the question related to below mentioned query? select e1.salary from employee3 e1 where 2= ( select count(distinct(e2.salary)) from employee3 e2 where e2.salary>=e1.salary ) 1) What the query returns? 2) How it works? - Detail explanation (what the sub query does, why it is (where 2=)....etc...Please?

5 Answers  


What are the triggers in sql?

0 Answers  


What do you know about normalization and de- normalization?

0 Answers  


What is the difference between SSAS 2000 and SSAS 2005?

1 Answers   APX,






Call by value and call by reference in procedure and function, with NOCOPY.

0 Answers   Nagarro,


How to round a numeric value to a specific precision?

0 Answers  


How do you connect 100 files as a flat file sources in one package of SSIS?

2 Answers  


What is the contrast amongst drop and truncate?

0 Answers  


What is the difference between NOROW and LOCKROW?

0 Answers   Accenture, Honeywell, Satyam,


What is sql server management studio? : sql server management studio

0 Answers  


I have a table EMP in which the values will be like this EmpId Ename Sal DeptId 11 Ram 10000 10 11 Ram 10000 10 22 Raj 20000 20 22 Raj 20000 20 33 Anil 15000 30 33 Anil 15000 30 I want to delete only duplicate Rows. After Delete I want the output like this EmpId Ename Sal DeptId 11 Ram 10000 10 22 Raj 20000 20 33 Anil 15000 30

13 Answers   DELL,


Categories