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
 General SQL Server Forums
 New to SQL Server Programming
 Easiest Way to Export Query Result to Excel

Author  Topic 

JohnGault777
Starting Member

31 Posts

Posted - 2011-02-28 : 15:06:11
I have a query that will return the results I need when I run it in SSMS. When I try to use Import Export Wizard to get the information to Excel it fails every try.

1. How is it possible for a query to work in SSMS but fail while exporting the exact same query?

2. I'm new to SQL, what is the simplest and easiest way to export a query to excel?

Additional information: I use the Export Wizard all the time. I never seem to have an issue. However, the query I'm running now is fairly complex. One of the tables I need to join breaks our all the different attributes of a single entry into different rows, so I had to turn rows into columns and the inner join the table to row entries I need. It works in SQL but will not export.

Is there a level of complexity that isn't allowed in the export function?

JG777

mikgri
Starting Member

39 Posts

Posted - 2011-03-01 : 12:07:00
Try to run query in SSMS, copy query results and past results to excel spread sheet. May be it will give you a clue what is going wrong with query result during export function, could be some restrictions for excel data types.
Just check it.
Go to Top of Page

MIK_2008
Master Smack Fu Yak Hacker

1054 Posts

Posted - 2011-03-01 : 12:33:29
You can use BCP,OpenRowSet,OpenDataSource methods to export data into Excel Sheet via executing Query in SSMS. For details please Google or http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926.


Cheers
MIK
Go to Top of Page

npatel.bi
Starting Member

1 Post

Posted - 2011-03-01 : 14:51:31
Best way to to is as follow:
1. Go to excel spreadsheet.
2.Click on DATA ---> From Other source---->From SQL Server---> Enter server name and follow the baby step and you will be all set.

-Nirav
Go to Top of Page
   

- Advertisement -