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 2005 Forums
 Transact-SQL (2005)
 How to save query result to Excel file?

Author  Topic 

Sun Foster
Aged Yak Warrior

515 Posts

Posted - 2009-02-12 : 11:22:25
I ran a query which display result as grid including column header.
How to save result to Excel file?
I used copy and paste but column header were missed.

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-12 : 11:25:38
you've option in sql mangement studio options menu which says copy column headers while copying results. just check it
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-02-12 : 11:26:23
or use this

http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/import-export-to-excel.aspx
Go to Top of Page

bklr
Master Smack Fu Yak Hacker

1693 Posts

Posted - 2009-02-12 : 23:10:53
try like this too
go to query --> results to file check the option and run the file

shortcut as ctrl+shift+f and run the query then it will ask to save file(.xls) give ur target destination
Go to Top of Page

Jai Krishna
Constraint Violating Yak Guru

333 Posts

Posted - 2009-02-12 : 23:24:14
To Include Column Header in the Result Set

Tools->Options->QueryResults->SQL Server->Results To Text->
Now Select Tab Limited Option in Output Format Combo Box
And Also Check Include Column Headers in the Result Test

Now Execute like this
query --> click results to file option and run the file

save file with extension(.xls)
When u save file save as type should be 'All Files'

Jai Krishna
Go to Top of Page
   

- Advertisement -