SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 How to Unpivot
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

vijays3
Constraint Violating Yak Guru

India
338 Posts

Posted - 03/11/2013 :  09:14:52  Show Profile  Reply with Quote
Hi All,




Furniture Retail Module 1	 Furniture Retail Module 2
Passed	                          Passed
Failed	                          Passed

How to display above data in following manner

ModuleName                      Result
Furniture Retail Module 1       Passed	
Furniture Retail Module 1       Failed
Furniture Retail Module 2       Passed
Furniture Retail Module 2       Passed

Kindly please suggest me on this.



Vijay is here to learn something from you guys.

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 03/11/2013 :  12:49:20  Show Profile  Reply with Quote

declare @test table
(
[Furniture Retail Module 1] varchar(100),
[Furniture Retail Module 2] varchar(100)
)
insert @test
SELECT 'Passed','Passed' UNION ALL
SELECT 'Failed','Passed'

SELECT ModuleName,Result
FROM @test t
UNPIVOT ( Result FOR ModuleName IN ([Furniture Retail Module 1],[Furniture Retail Module 2]))u
ORDER BY ModuleName


output
-----------------------------------------------------------
ModuleName	                Result
-----------------------------------------------------------
Furniture Retail Module 1	Passed
Furniture Retail Module 1	Failed
Furniture Retail Module 2	Passed
Furniture Retail Module 2	Passed



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page

vijays3
Constraint Violating Yak Guru

India
338 Posts

Posted - 03/12/2013 :  05:08:17  Show Profile  Reply with Quote
Thanks Visakh..

Vijay is here to learn something from you guys.
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52249 Posts

Posted - 03/12/2013 :  05:13:45  Show Profile  Reply with Quote
welcome

------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/

Go to Top of Page
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.08 seconds. Powered By: Snitz Forums 2000