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.
| Author |
Topic |
|
mahesh_bote
Constraint Violating Yak Guru
298 Posts |
Posted - 2006-10-19 : 09:08:29
|
| hi,i have one table with three columns.i.e.A B C ---> Columns1 2 3 ---> Data3 2 1 ---> Data1 3 2 ---> Datanow i want o/p likeColumnName ValueA 1B 2C 3A 3B 2C 1A 1B 3C 2its an example, actually i have nearabt 54 columns and i want to return them in mentined manner.thanks in advance,Mahesh |
|
|
nr
SQLTeam MVY
12543 Posts |
Posted - 2006-10-19 : 09:23:33
|
| select columnname = 'A', value = A from tblunion allselect columnname = 'B', value = B from tblunion allselect columnname = 'C', value = C from tbl==========================================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. |
 |
|
|
mahesh_bote
Constraint Violating Yak Guru
298 Posts |
Posted - 2006-10-20 : 02:50:05
|
| thanks,but as i have mentioned earlier, i have table with 54 columns and it contains 65 rows. i wants to write the sql statement which will show the value beside the columns name.Mahesh |
 |
|
|
khtan
In (Som, Ni, Yak)
17689 Posts |
Posted - 2006-10-20 : 03:01:36
|
quote: Originally posted by mahesh_bote thanks,but as i have mentioned earlier, i have table with 54 columns and it contains 65 rows. i wants to write the sql statement which will show the value beside the columns name.Mahesh
Just add on to the union all as what nr had demonstrate hereselect columnname = 'A', value = A from tblunion allselect columnname = 'B', value = B from tblunion allselect columnname = 'C', value = C from tblunion allselect columnname = 'D', value = D from tbl KH |
 |
|
|
DonAtWork
Master Smack Fu Yak Hacker
2167 Posts |
Posted - 2006-10-20 : 06:44:40
|
when i see "now i want o/p like" i read it as "Now i want to present the data in this format", and that type of operation is best done in the Madhi.I mean front end. [Signature]For fast help, follow this link:http://weblogs.sqlteam.com/brettk/archive/2005/05/25.aspxLearn SQLhttp://www.sql-tutorial.net/ http://www.firstsql.com/tutor.htm http://www.w3schools.com/sql/default.asp |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-10-21 : 06:53:24
|
>> and that type of operation is best done in the Madhi. MadhivananFailing to plan is Planning to fail |
 |
|
|
madhivanan
Premature Yak Congratulator
22864 Posts |
Posted - 2006-10-21 : 06:58:38
|
quote: Originally posted by mahesh_bote hi,i have one table with three columns.i.e.A B C ---> Columns1 2 3 ---> Data3 2 1 ---> Data1 3 2 ---> Datanow i want o/p likeColumnName ValueA 1B 2C 3A 3B 2C 1A 1B 3C 2its an example, actually i have nearabt 54 columns and i want to return them in mentined manner.thanks in advance,Mahesh
Where do you want to show data?If you use vb or asp you can very well do there.It cant be done in sql easily as you expectMadhivananFailing to plan is Planning to fail |
 |
|
|
|
|
|
|
|