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 2008 Forums
 Transact-SQL (2008)
 Display Data of a Table vertically in sql server

Author  Topic 

anupama96
Starting Member

2 Posts

Posted - 2011-05-14 : 06:26:07
Hi,

I am a beginner to sqlserver.here is my problem.
i have a table data as below
Id Period1 Period2 Period3 Period4 Period5
5 09.30-10.20 10.20-11.10 11.10-12.00 12:00-12:50 12.50-01.40

i want it to be displayed as
09.30-10.20
10.20-11.10
11.10-12.00
12:00-12:50
12.50-01.40

i have tried using row_number but i didnt get as i required.

any suggestions??

thanks in advance




AnupamaBommaraju

khtan
In (Som, Ni, Yak)

17689 Posts

Posted - 2011-05-14 : 06:41:04
[code]
select period
from yourtable t
unpivot
(
period
for col in ([Period1], [Period2], [Period3], [Period4], [Period5])
) p
[/code]


KH
[spoiler]Time is always against us[/spoiler]

Go to Top of Page

anupama96
Starting Member

2 Posts

Posted - 2011-05-16 : 03:39:03
Thanks for the quick reply...

It was really helpful


quote:
Originally posted by khtan


select period
from yourtable t
unpivot
(
period
for col in ([Period1], [Period2], [Period3], [Period4], [Period5])
) p



KH
[spoiler]Time is always against us[/spoiler]





AnupamaBommaraju
Go to Top of Page
   

- Advertisement -