What you want to see on DotNetFunda.com ?
DotNetFunda.Com Logo
Twitter TwitterLinkedIn
YouTubeGoogle
 Online : 18589 |  Welcome, Guest!   Register  Login
 Home > Code Snippets > SQL Server > UNPIVOT in SQL SERVER 2008 ...
CGN007

UNPIVOT in SQL SERVER 2008

 Code Snippet posted by: CGN007 | Posted on: 6/22/2012 | Category: SQL Server Codes | Views: 467 | Status: [Member] | Points: 40 | Alert Moderator   


Input Table

VendorID Rahul Sourav Sunil
-------------------------------------
1 5 3 9
2 8 4 6

SELECT VendorID,EmployeeName,Orders

FROM tempCTE
UNPIVOT
(Orders FOR EmployeeName IN ([Rahul],[Sourav],[Sunil]) )AS unpvt




Output

VendorID EmployeeName Orders
--------------------------------------
1 Rahul 5
1 Sourav 3
1 Sunil 9
2 Rahul 8
2 Sourav 4
2 Sunil1 6
Found interesting? Add this to:


>> Write Response - Respond to this post and get points

More codes snippets

About Us | Contact Us | The Team | Advertise | Software Development | Write for us | Testimonials | Privacy Policy | Terms of Use | Link Exchange | Members | Go Top
General Notice: If you find plagiarised (copied) contents on this page, please let us know the original source along with your correct email id (to communicate) for further action.
Copyright © DotNetFunda.Com. All Rights Reserved. Copying or mimicking the site design and layout is prohibited. Logos, company names used here if any are only for reference purposes and they may be respective owner's right or trademarks. | 5/25/2013 5:27:30 AM