I have database in structure like below Newspaper State1 state2 state3 state4 ABC 1000 5684 5687 246 DEF 879 2547 2578 2357 But I need to the structure like below How can i change this Newspaper State copies ABC State1 1000 ABC State2 5684 ABC State3 5687 ABC State4 246 DEF State1 879 DEF State2 2547 DEF State3 2578 DEF State4 2357
SELECT [NewsPaper] ,[State],[Copies] FROM (SELECT [NewsPaper] ,[State1] ,[State2] ,[State3] ,[State4] FROM [Test].[dbo].[News]) p UNPIVOT (Copies FOR State IN (State1,State2,State3,State4) )AS unpvt; GO
var
This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)