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 2000 Forums
 Import/Export (DTS) and Replication (2000)
 import to XLS sheet

Author  Topic 

t.herrin
Starting Member

1 Post

Posted - 2002-02-08 : 17:51:19
has anyone here tried exporting a query result to xls sheet thru stored procedure?

thanks.

rrb
SQLTeam Poet Laureate

1479 Posts

Posted - 2002-02-09 : 07:24:02
quote:

has anyone here tried exporting a query result to xls sheet thru stored procedure?

thanks.


Why can't you use DTS - (about 4 mouse clicks) - What's the issue?

--
I hope that when I die someone will say of me "That guy sure owed me a lot of money"
Go to Top of Page

Spyder
SQLTeam Author

75 Posts

Posted - 2002-02-10 : 05:57:29
This seems to work pretty well for me. You can run this from the command line or via xp_cmdshell. Just be sure that you put a TAB character between the quotation marks of the -s parameter -- this makes your output tab-delimited. Making the output file extension ".xls" fools Excel into opening what is actually a tab-delimited text file.

osql -Uusername -Ppwd -s" " -w1000 -Q"SELECT col1, col2 FROM YourDB.dbo.tablename WHERE foo='bar'" -oC:\Directory\Filename.xls



Go to Top of Page
   

- Advertisement -