SQL Server - copy header when query executed - Asked By farrukh on 04-Nov-11 11:00 AM

Hi All
 I need some help...


how to copy the header of columns .

When i right click and  select new view and  then add table to make sql query , i need to copy the header of the results and data . When i right click and copy it only copy the data not the header ?

any idea

thanks
hameed
Adam replied to farrukh on 04-Nov-11 11:15 AM
In SQL server once you execute a query you can highlight the whole result set and right click on the result set and there is an option that says "Copy with Headers".  However, it sounds like you are trying to accomplish something else, would you give more detail as to what you are doing? Thanks.
farrukh replied to Adam on 04-Nov-11 11:26 AM

Hi Adam,

I am new to sql server in views folder when i right click there is an option new view and then add table when i add the views the sql statement auto create.

when i execute this query it gives me some results , i need to header as well but there is only option available   which are execute,cut,copy,paste,pane,clear results.?

How to copy the header ?

Thanks 
hameed 
Adam replied to farrukh on 04-Nov-11 11:39 AM
So under the Views folder you should see the view that you created?  If so, open a blank query window and do a SELECT * FROM viewName

That should give you a results pane at the bottom and from there do the select all and right click 'Copy with Headers'
Kirtan Patel replied to farrukh on 04-Nov-11 12:22 PM
  1. In SSMS, open Tools menu and click Options
  2. Expand Query Results node and click Results to Grid
  3. Check Include column headers when copying or saving the results. Your screen will look similar to following:
  4. Click Save to save your settings.
farrukh replied to Kirtan Patel on 04-Nov-11 03:51 PM
Hi,


Thanks alot Adam and Kirtan for your kind help...

Thanks
hameed