How to display data horizontally in SQL Server?
<p>How do I display my table data horizontally?</p>

<p>This is my table definition</p>

<pre><code>create table [User]
(
    Id int primary key identity(1,1),
    Name varchar(50),
    Gender varchar(10)
)
</code></pre>

<p>This is the data I have in my SQL Server table</p>

<pre><code>+====+=======+========+
| Id | Name  | Gender |
+====+=======+========+
| 1  | Fahad | Male   |
+----+-------+--------+
| 2  | Saad  | Male   |
+----+-------+--------+
| 3  | Asif  | Male   |
+====+=======+========+
</code></pre>

<p>and I want to show it horizontally like this</p>

<pre><code>+========+=======+======+======+
| Id     | 1     | 2    | 3    |
+========+=======+======+======+
| Name   | Fahad | Saad | Asif |
+--------+-------+------+------+
| Gender | Male  | Male | Male |
+========+=======+======+======+
</code></pre>