Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Copying the Headers of Result Set of Select statement

Copying the Headers of Result Set of Select statement

Scheduled Pinned Locked Moved Database
help
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • I Offline
    I Offline
    indian143
    wrote on last edited by
    #1

    Hi, I am trying to copy just the Headers of a result set of a select statement, normally I am able to do by select only one row, but I want to get it even if the Resultset has empty rows. Please need some help. - Thanks in advance. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

    J M 2 Replies Last reply
    0
    • I indian143

      Hi, I am trying to copy just the Headers of a result set of a select statement, normally I am able to do by select only one row, but I want to get it even if the Resultset has empty rows. Please need some help. - Thanks in advance. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

      J Offline
      J Offline
      JChrisCompton
      wrote on last edited by
      #2

      For SQL Server Management Studio (SSMS) you can go to Tools | Options Within Options: Query Results | SQL Server | Results to Grid When you can select a row, copy it and you get the headers (plus the selected rows). Unless, you only have one column or you have an empty result set - then it doesn't work. You can either (1) change your result to text [CTRL]+"D" and see the headings (also Tools | Options | Query Results | SQL Server | General, select Results to Grid) or (2) you can select the "Include the query in the result set" (though presumably you already have the query). Hope that helps, -Chris C.

      1 Reply Last reply
      0
      • I indian143

        Hi, I am trying to copy just the Headers of a result set of a select statement, normally I am able to do by select only one row, but I want to get it even if the Resultset has empty rows. Please need some help. - Thanks in advance. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

        M Offline
        M Offline
        Mycroft Holmes
        wrote on last edited by
        #3

        Try Select * from Table where 1=1

        Never underestimate the power of human stupidity RAH

        I 1 Reply Last reply
        0
        • M Mycroft Holmes

          Try Select * from Table where 1=1

          Never underestimate the power of human stupidity RAH

          I Offline
          I Offline
          indian143
          wrote on last edited by
          #4

          Actually its not a problem of where condition, because where 1=1 is nothing but not having where clause itself like

          Select * from Employee is same as Select * from Employee where 1=1

          The table itself doesn't have any data but still I want to copy the Header names as there are 45 Columns in that table for example and i don't want to expand the Columns of the table in Management studio in that way I can do, but just want get it from select resultset. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

          M 1 Reply Last reply
          0
          • I indian143

            Actually its not a problem of where condition, because where 1=1 is nothing but not having where clause itself like

            Select * from Employee is same as Select * from Employee where 1=1

            The table itself doesn't have any data but still I want to copy the Header names as there are 45 Columns in that table for example and i don't want to expand the Columns of the table in Management studio in that way I can do, but just want get it from select resultset. Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

            M Offline
            M Offline
            Mycroft Holmes
            wrote on last edited by
            #5

            You want to explore the Information_Schema views

            SELECT COLUMN_NAME
            FROM INFORMATION_SCHEMA.COLUMNS
            WHERE TABLE_NAME = 'Country'

            Never underestimate the power of human stupidity RAH

            I 1 Reply Last reply
            0
            • M Mycroft Holmes

              You want to explore the Information_Schema views

              SELECT COLUMN_NAME
              FROM INFORMATION_SCHEMA.COLUMNS
              WHERE TABLE_NAME = 'Country'

              Never underestimate the power of human stupidity RAH

              I Offline
              I Offline
              indian143
              wrote on last edited by
              #6

              Yeah that makes sense - thanks a lot Thanks, Abdul Aleem "There is already enough hatred in the world lets spread love, compassion and affection."

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups