Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Copy query results to Excel

Author  Topic 

CoffeeAddict
Yak Posting Veteran

94 Posts

Posted - 2010-06-09 : 17:38:32
Does anyone know how to copy query results successfully into Excel via SQL 2008 Management Studio?

I've been unsuccessful. The copy commands suck.

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2010-06-09 : 18:38:47
Works just fine for me.

Assuming you are using the data grid view and want everything, click the upper-left corner (above the #1 in the first row) or right-click in the data grid and select "Select All" to highlight eveything. Then CTRL-C or right click and select "Copy" or "Copy with Headers." Go to Excel and CTRL-V or right-click and selcet Paste.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-06-10 : 03:13:07
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

CoffeeAddict
Yak Posting Veteran

94 Posts

Posted - 2010-06-10 : 10:36:01
Sorry, Data Grid View?

Also some more info:

1) I'm using Office 2010, so Excel 2010
2) I'm just running the query, highlighting all rows in the results panel and copying into the excel spreadsheet
3) I've also tried to save as a .csv but when I open it in Excel it's not seperating out in terms of rows at all.

When I copy and paste into an excel spreadsheet, it seems to be combining all rows and data in one cell!
Go to Top of Page

CoffeeAddict
Yak Posting Veteran

94 Posts

Posted - 2010-06-10 : 10:36:47
Has anyone tried that with Office 2010 madhivanan? I guess I'll try some of those export stripts and report back.
Go to Top of Page

CoffeeAddict
Yak Posting Veteran

94 Posts

Posted - 2010-06-10 : 10:45:03
As expected, does not run in SQL 2008:

Here's what I ran:

insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=C:\Users\Mark\Desktop\RecipientErrors.xlsx;',
'SELECT * FROM [Errors$]')
select email, createdate, actionID, ListID, MailingID, RecipientID, JobID, SOAPSent
from ApiFailures
where CreateDate >= '2010-06-05 16:15:14.650'
order by CreateDate desc

OLE DB provider 'Microsoft.Jet.OLEDB.4.0' cannot be used for distributed queries because the provider is configured to run in single-threaded apartment mode.

We are running 64 bit (SQL, Windows Server, etc.)
Go to Top of Page

CoffeeAddict
Yak Posting Veteran

94 Posts

Posted - 2010-06-10 : 12:09:43
Lodi Dodi, we likes to party. I'm still trying to teak this for use with SQL 2008 and Excel 2010. I'll figure out out shortly.
Go to Top of Page

CoffeeAddict
Yak Posting Veteran

94 Posts

Posted - 2010-06-10 : 12:10:05
HAWKS WIN HAWKS WIN!!!
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2010-06-11 : 02:23:00
quote:
Originally posted by CoffeeAddict

HAWKS WIN HAWKS WIN!!!


What do you mean?

Madhivanan

Failing to plan is Planning to fail
Go to Top of Page

CoffeeAddict
Yak Posting Veteran

94 Posts

Posted - 2010-06-11 : 10:49:31
Blackhawks baby!

quote:
Originally posted by madhivanan

quote:
Originally posted by CoffeeAddict

HAWKS WIN HAWKS WIN!!!


What do you mean?

Madhivanan

Failing to plan is Planning to fail

Go to Top of Page

CoffeeAddict
Yak Posting Veteran

94 Posts

Posted - 2010-06-21 : 10:21:38
Ok I've gotten nowhere on this I cannot believe it's this hard to take grid data out of the query analyzer result set and shove it into Excel using Office 2010. I still can't get those scripts to run because I do not have access to the prod server in order to install the needed ODBC drivers for that. There has to be a better option than these sql scripts-to-Excel?
Go to Top of Page
   

- Advertisement -