Hi jimioh,
While cletus's query is correct, it's worth pointing out that you can use the keyword UNPIVOT in SQL Server 2005 and later to do almost the same thing:
select
period, nameOfVehicle, value
from T unpivot (
value for nameOfVehicle in ([Car],[Truck],[Boat])
) as U;
The difference between UNPIVOT and cletus's solution is that UNPIVOT will not include rows for which [value] IS NULL. If you need the NULLs, you'll have to be somewhat sneaky and use a value that can never occur in the table (here I use an empty string):
with X(period,Car,Truck,Boat) as (
select period,coalesce(Car,''),coalesce(Truck,''),coalesce(Boat,'')
from T
)
select
period, nameOfVehicle, case when value = '' then null else value end as value
from X unpivot (
value for nameOfVehicle in ([Car],[Truck],[Boat])
) as U;
Depending on the columns you'll keep after unpivoting, this may be another option (this solution will retain the NULL values):
select
period,
nameOfVehicle,
max(case nameOfVehicle
when 'Truck' then Truck
when 'Car' then Car
when 'Boat' then Boat end) as value
from T cross join (
values ('Truck'),('Car'),('Boat')
) as Columns(nameOfVehicle)
group by period, nameOfVehicle;