Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 First Row as column names

Author  Topic 

mrsaif
Starting Member

43 Posts

Posted - 2006-04-05 : 06:44:11
I have a table containing 4 rows. I want to get all records and first row as the column names.
the data in my table is in this format.
id name NIC
1 Kalo 2354789
2 Bhasha 1254799
3 Tata 1245454
How should I do this

Muhammad Saifullah

nr
SQLTeam MVY

12543 Posts

Posted - 2006-04-05 : 06:46:13
select 'id, 'name', 'NIC'
union all
select convert(varchar(20),id) , name, convert(varchar(20),NIC) from tbl

It's an odd thing to want to do though.



==========================================
Cursors are useful if you don't know sql.
DTS can be used in a similar way.
Beer is not cold and it isn't fizzy.
Go to Top of Page

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2006-04-05 : 07:01:14
quote:
Originally posted by mrsaif

I have a table containing 4 rows. I want to get all records and first row as the column names.


Why do you want do to this ?



KH


Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2006-04-05 : 08:56:05
Note that if you use this in query all datatypes should be of varchar type. Use Front end application to show the column names from recordset

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page
   

- Advertisement -