By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,203 Members | 1,633 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,203 IT Pros & Developers. It's quick & easy.

Query to produce column names at top of results?

P: 4
Hello,
We're using SQL Server 2000 and Query Manager (not Visual Studio). When your query results are returned, the column names are displayed at the top, but this information is NOT available for cut/paste to Excel. One of the workarounds we thought of was to return the column names within the query itself, and thought there was perhaps an option or other feature of SQL Server that would allow us to put the column headings into Excel without having the type in the column names. Ideas/suggestions are appreciated.
Thanks
Oct 18 '07 #1
Share this Question
Share on Google+
1 Reply


Jim Doherty
Expert 100+
P: 897
Hello,
We're using SQL Server 2000 and Query Manager (not Visual Studio). When your query results are returned, the column names are displayed at the top, but this information is NOT available for cut/paste to Excel. One of the workarounds we thought of was to return the column names within the query itself, and thought there was perhaps an option or other feature of SQL Server that would allow us to put the column headings into Excel without having the type in the column names. Ideas/suggestions are appreciated.
Thanks
Heres one to add to your arsenal, adjust to suit you

Expand|Select|Wrap|Line Numbers
  1.  CREATE PROCEDURE dbo.usp_MakeSpreadsheet AS 
  2. exec sp_makewebtask @outputfile = 'c:\myspreadsheet.xls', 
  3.     @query = 'Select * from dbo.MyTable',
  4.     @colheaders =1, 
  5. @FixedFont=0,@lastupdated=0,@resultstitle='Here are the results',
  6.     @dbname ='NameOfYourDatabase'
  7. GO
  8.  
Regards

Jim :)
Oct 19 '07 #2

Post your reply

Sign in to post your reply or Sign up for a free account.