title: Get column names from first row of SQL Server table
body: <p>I have 2 tables first table have field names having below structure.</p>
  
  <pre><code>CREATE TABLE [dbo].[FieldNames](
      [SiteId] [int] NULL,
      [Column_1] [nvarchar](50) NULL,
      [Column_2] [nvarchar](50) NULL,
      [Column_3] [nvarchar](50) NULL,
      [Name] [nvarchar](50) NULL
  ) ON [PRIMARY]
  </code></pre>
  
  <p>This table contains below data</p>
  
  <pre><code>1   FirstName   LastName    City    Coutry
  2   City        Coutry      Name    Gender
  </code></pre>
  
  <p>I have another table contains column values having below structure.</p>
  
  <pre><code>CREATE TABLE [dbo].[FieldValue](
      [RowId] [int] NULL,
      [SiteId] [int] NULL,
      [Column1_Value] [nvarchar](50) NULL,
      [Column2_Value] [nvarchar](50) NULL,
      [Column3_Value] [nvarchar](50) NULL,
      [Name] [nvarchar](50) NULL
  ) ON [PRIMARY]
  </code></pre>
  
  <p>This table contains below data.</p>
  
  <pre><code>1   1   ABC     XYZ     Ahmedaad    India
  2   1   Hello   Smith   Kodiar  India
  3   2   Ahmedaad    India   Happy   data
  </code></pre>
  
  <p>I want the result  something like below for <code>siteid = 1</code></p>
  
  <pre><code>**FirstName     LastName     City     Coutry**
  ABC             XYZ          Ahmedaad India
  Hello           Smith        Kodiar   India
  </code></pre>