Copying the Headers of Result Set of Select statement
-
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."
-
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."
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.
-
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."
Try Select * from Table where 1=1
Never underestimate the power of human stupidity RAH
-
Try Select * from Table where 1=1
Never underestimate the power of human stupidity RAH
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."
-
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."
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
-
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