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.Select values from multiple columns into single column in SQL Server<p>Hi <a class="username" rel="chetan"> chetan</a>,</p> <p>Refer below sample.</p> <pre class="brush: sql">DECLARE @TestDemo AS TABLE(Name1 VARCHAR(10),Name2 VARCHAR(10),Department1 VARCHAR(10),Department2 VARCHAR(10),Location1 VARCHAR(10),Location2 VARCHAR(10)) INSERT INTO @TestDemo VALUES(&#39;Jhon&#39;,&#39;Alex&#39;,&#39;IT&#39;,&#39;Marketing&#39;,&#39;London&#39;,&#39;Seattle&#39;) INSERT INTO @TestDemo VALUES(&#39;Mark&#39;,&#39;Dan&#39;,&#39;Sales&#39;,&#39;R&amp;D&#39;,&#39;Paris&#39;,&#39;Tokyo&#39;) SELECT Name1 &#39;Name&#39;,Department1 &#39;Department&#39;,Location1 &#39;Location&#39; FROM @TestDemo UNION ALL SELECT Name2 &#39;Name&#39;,Department2 &#39;Department&#39;,Location2 &#39;Location&#39; FROM @TestDemo</pre> <p><span style="text-decoration: underline;"><strong>Output</strong></span></p> <table border="1"> <tbody> <tr style="height: 15.0pt;"> <td style="height: 15.0pt; width: 48pt;" width="64" height="20"><strong>Name</strong></td> <td style="width: 48pt;" width="64"><strong>Department</strong></td> <td style="width: 48pt;" width="64"><strong>Location</strong></td> </tr> <tr style="height: 15.0pt;"> <td style="height: 15.0pt;" height="20">Jhon</td> <td>IT</td> <td>London</td> </tr> <tr style="height: 15.0pt;"> <td style="height: 15.0pt;" height="20">Mark</td> <td>Sales</td> <td>Paris</td> </tr> <tr style="height: 15.0pt;"> <td style="height: 15.0pt;" height="20">Alex</td> <td>Marketing</td> <td>Seattle</td> </tr> <tr style="height: 15.0pt;"> <td style="height: 15.0pt;" height="20">Dan</td> <td>R&amp;D</td> <td>Tokyo</td> </tr> </tbody> </table>https://www.aspforums.net:443/Threads/132585/Select-values-from-multiple-columns-into-single-column-in-SQL-Server/https://www.aspforums.net:443/Threads/132585/Select-values-from-multiple-columns-into-single-column-in-SQL-Server/Wed, 15 May 2019 00:22:37 GMT