Hi All,
I want to display the data in vertical format though the data is stored horizontally in the datatable.Suppose i have table with five columns-id.a,b,c,d.If i use a select statement that will give me the data in the format-ID A B C D
but now i want to display the data as
ID A
ID B
ID C
ID D
Any help on this pls??I m thinking to use the self join but would it take a long time??
Thanks
select id,a
union
select id,b
union
select id,c
union
select id,d
|||It sounds to me more like you require a pivot query rather than a union. If you have Sql Server 2005 you can do pivot queries but, unfortunately, not in the older versions. There a good article you can readhere that explains how to do pivot queries.|||You can do pivot tables in Sql Server 2000. Just search for "pivot tables" in the Books Online. The example there was greatly helpful to me with the same issue.
Hope this helps
No comments:
Post a Comment