Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

source unpivot(PIVOT and UNPIVOT) Expand / Collapse
Author
Message
Posted Wednesday, July 28, 2010 12:42 AM
SSC Rookie

SSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC RookieSSC Rookie

Group: General Forum Members
Last Login: Monday, November 1, 2010 4:19 AM
Points: 39, Visits: 150
Does anyone know the source unpivot syntax? I cannot find it from google. Thanks!
Post #959852
Posted Wednesday, July 28, 2010 3:35 PM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Wednesday, March 19, 2014 9:54 AM
Points: 241, Visits: 442
look through this post by pinal dave

http://blog.sqlauthority.com/2008/05/29/sql-server-unpivot-table-example/


--------------------------

I long for a job where my databases dont have any pesky users accessing them :)
Post #960385
Posted Thursday, November 15, 2012 6:30 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Today @ 11:53 AM
Points: 87, Visits: 610
Check out this example using unpivot

http://wordpress.robertdavidian.com/?p=12
Post #1385410
Posted Thursday, November 15, 2012 7:43 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Thursday, November 15, 2012 7:33 PM
Points: 9, Visits: 0




Post #1385424
Posted Thursday, November 15, 2012 8:44 PM


Hall of Fame

Hall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of FameHall of Fame

Group: General Forum Members
Last Login: Yesterday @ 4:49 PM
Points: 3,427, Visits: 5,378
changbluesky (7/28/2010)
Does anyone know the source unpivot syntax? I cannot find it from google. Thanks!


The syntax is in this article along with perhaps a better way:
http://www.sqlservercentral.com/articles/CROSS+APPLY+VALUES+UNPIVOT/91234/



My mantra: No loops! No CURSORs! No RBAR! Hoo-uh!

My thought question: Have you ever been told that your query runs too fast?

My advice:
INDEXing a poor-performing query is like putting sugar on cat food. Yeah, it probably tastes better but are you sure you want to eat it?
The path of least resistance can be a slippery slope. Take care that fixing your fixes of fixes doesn't snowball and end up costing you more than fixing the root cause would have in the first place.


Need to UNPIVOT? Why not CROSS APPLY VALUES instead?
Since random numbers are too important to be left to chance, let's generate some!
Learn to understand recursive CTEs by example.
Splitting strings based on patterns can be fast!
Post #1385438
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse