Jacob Wilkins (2/12/2016)
Luis Cazares (2/12/2016)
Jacob Wilkins (2/12/2016)
No need to use window functions. A simple CROSS APPLY will do the trick.
SELECT [OrderNumber]=OrderID,
[User]=x.[User]
FROM dbo.Orders CROSS APPLY (SELECT [User]=EnteredBy
UNION ALL
SELECT [User]=PerformedBy
) x([User])
Cheers!
Or the short version available since 2008.
SELECT [OrderNumber]=OrderID,
[User]=x.[User]
FROM dbo.Orders
CROSS APPLY (VALUES( EnteredBy),
(PerformedBy)) x([User]);
Heh, good point. Went on autopilot using the old stuff; one day I won't have to worry about 2005...one day. 🙂
I know it's just me but I like the "old stuff". It's just as fast as the new stuff, as well. Guess it's a matter of what you cut your teeth on.
--Jeff Moden
Change is inevitable... Change for the better is not.