August 19, 2008 at 7:24 pm
Need help in translating the below SQL Server 2005 code into SQL Server 2000.
Basically I need to re-write the below query without PIVOT, so that I can run in SQL Server 2000.
SELECT
UP.RecordID,
UP.StopNumber,
CASE StopNumberType
WHEN 'OrigTerminalStopNumber' THEN 'OT'
WHEN 'OrigRampStopNumber' THEN 'OR'
WHEN 'LoadingPortStopNumber' THEN 'OP'
WHEN 'DischargePortStopNumber' THEN 'DP'
WHEN 'DestRampStopNumber' THEN 'DR'
WHEN 'DestTerminalStopNumber' THEN 'DT'
END AS LocationType
FROM
(
SELECT
IL.RecordID,
IL.DestRampStopNumber,
IL.DestTerminalStopNumber,
IL.DischargePortStopNumber,
IL.LoadingPortStopNumber,
IL.OrigRampStopNumber,
IL.OrigTerminalStopNumber
FROM Table1 AS IL
) AS P
UNPIVOT
(
StopNumber FOR StopNumberType IN
(
P.DestRampStopNumber,
P.DestTerminalStopNumber,
P.DischargePortStopNumber,
P.LoadingPortStopNumber,
P.OrigRampStopNumber,
P.OrigTerminalStopNumber
)
) AS UP
Any help will be appreciated!
August 19, 2008 at 8:15 pm
Check out this article, http://www.sqlservercentral.com/articles/T-SQL/63681/, it is about exactly what you are talking about.
Jack Corbett
Consultant - Straight Path Solutions
Check out these links on how to get faster and more accurate answers:
Forum Etiquette: How to post data/code on a forum to get the best help
Need an Answer? Actually, No ... You Need a Question
August 19, 2008 at 10:54 pm
Thanks Jack for the link. I am actually looking for information on UNPIVOT.
I know there's a type in the header...
Viewing 3 posts - 1 through 3 (of 3 total)
You must be logged in to reply to this topic. Login to reply