SQLTeam.com | Weblogs | Forums

How can i convert these rows into colums sqlserver

Froms Tos Shift Code Rank
06:00 07:10 Before Early Morning AM T1
07:10 09:10 Early Morning AM T2
09:10 10:30 Morning AM T3
11:00 01:00 After Break PM T4
02:00 03:20 After Lunch PM T5
03:20 04:40 Evening Session PM T6
08:00 09:20 Early Prep PM T7
09:20 10:30 Late Prep PM T8

T1 06:00 07:10 Before Early Morning T2 07:10 09:10 Early Morning

please google search lots of articles

how many columns does the expected output have? Also provide your data not as an embedded table but as a reusable table as follows

declare @sample table(Froms varchar(50), Tos varchar(50) )

isnert into @sample
select '06:00', '07:10'

etc etc