December 18, 2007 at 5:02 am
Hi, I'm trying to run some data from query analyser and then extract this onfo in excel.
As there a lot of columns in analyser I want to copy the column names into excel.
is there any way to get the column name ?
Regards
Ritesh
December 18, 2007 at 5:44 am
One way run the query results to text, copy the results to Excel. The data will all be paced in the first column, highlight the column and use the Data option from the menu in Excel and altering the text to columns.... Not great but it does work.
December 18, 2007 at 6:16 am
I usually do the following:
Right Click on Query
Query Option | Text
Switch to comma delimited
change results window to text
run query
Right click in results window
save results as csv
Open in Excel
December 31, 2007 at 11:10 am
Click Query (Located on the main toolbar) --> Query Options --> Results --> Grid --> Include Column headers....(This should be checked)
Then select all the rows from your result set and copy --> open Excel and paste.
December 31, 2007 at 12:43 pm
If you setup Query Analyzer in the Text mode and use Tab's to delimit the data instead of commas, you can copy and paste directly from the Text results window of QA into Excel without all the extra steps.
--Jeff Moden
Change is inevitable... Change for the better is not.
December 31, 2007 at 2:01 pm
Jeff,
Ritesh still should have to make sure the column header query option is set wheter it be for text or grid. Ritesh will only have to configure this on the inital run. Any subsesequent queries can be copied/pasted, without changing this setting.
You can copy/paste rows directly from the results grid to Excel, without using tab delimited results to text.
December 31, 2007 at 2:07 pm
True enough. Just listing options, Adam...
--Jeff Moden
Change is inevitable... Change for the better is not.
January 2, 2008 at 11:00 am
Click Query (Located on the main toolbar) --> Query Options --> Results --> Grid --> Include Column headers....(This should be checked)
Just checking because I'm not entirely sure, but is the option to copy column names in the output an option of Query Analyzer? I'm seeing the option in Management Studio, but not QA. I'm not seeing the Query Options menu under Query on QA at all.
Is there actually a way to set this in QA, or is it just a SSMS setting?
January 2, 2008 at 11:08 am
If you're using SQL 2005, then SSMS IS Query analyzer as well... They are not 2 seperate tools like they were in 2000.
January 2, 2008 at 11:19 am
Sorry, I guess I should have paid attention to the fact that the post is under SQL Server 2005. I've tried to avoid referring to the SSMS query windows as Query Analyzer just to avoid confusion when dealing with folks who use both. :blush:
January 2, 2008 at 11:25 am
Use Excel itself to import the data as:
Open EXCEL
In main menu click "Data"
In drop down menu click "Import External Data"
In next drop down menu click "Import Data"
Select data source window appears
In that window select " +New SQL Server Connection.odc"
Click "Open" command button
Complete the Data Connection Wizard" (Server name and log on credentals)
In next window of Wizard select the database you wish to retrieve data from.
Clear the Select to a specific table check box
Click Next - input description Click Next
Select a table name - click OK
In next window click on Edit Query
In next window click on Command Type
SELECT SQL
In command text window replace table name with the name of the stored procedure that will retrieve the data.
"Pubs"."dbo"."test_exel"
Click OK
Click OK
Viewing 11 posts - 1 through 10 (of 10 total)
You must be logged in to reply to this topic. Login to reply