ASPForums.Net RSS Feedhttp://www.aspforums.net/Handlers/RSS.ashxLatest additions to the content that appears on ASPForums.Net(c) 2019 www.aspforums.com. All rights reserved.Display data horizontally using UNPIVOT in SQL Server<p>Hi <a class="username" rel="abc"> abc</a>,</p> <p>Refer below sample query.</p> <p><span style="text-decoration: underline;"><strong>SQL</strong></span></p> <pre class="brush: sql">CREATE TABLE #TestCustomers(Id VARCHAR(20), Name VARCHAR(20), [Address] VARCHAR(20)) INSERT INTO #TestCustomers VALUES(1,&#39;abc&#39;,&#39;Pune&#39;) SELECT DISTINCT [Column A] ,[Column B] FROM (SELECT [Id],[Name],[Address] FROM #TestCustomers) p UNPIVOT ([Column B] FOR [Column A] IN ([Id],[Name],[Address]) )AS unpvt; DROP TABLE #TestCustomers</pre> <p><span style="text-decoration: underline;"><strong>Output</strong></span></p> <table border="1"> <tbody> <tr> <td><strong>Column A</strong></td> <td><strong>Column B</strong></td> </tr> <tr> <td>Address</td> <td>Pune</td> </tr> <tr> <td>Id</td> <td>1</td> </tr> <tr> <td>Name</td> <td>abc</td> </tr> </tbody> </table>https://www.aspforums.net:443/Threads/574311/Display-data-horizontally-using-UNPIVOT-in-SQL-Server/https://www.aspforums.net:443/Threads/574311/Display-data-horizontally-using-UNPIVOT-in-SQL-Server/Mon, 01 Jul 2019 06:00:41 GMT