Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations biv343 on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to export a table to Excel within a stored proc?

Status
Not open for further replies.

steve728

Programmer
Mar 16, 2003
536
US
Once I'm done gathering data into a table I need to export it to an Excel Spreadsheet or a .csv file. Is it possible to do this from within a stored procedure? If so please show me an example of the typeical code.

Thanks in Advance!

Steve728
 
SQL2K5:

ms-help://MS.SQLCC.v9/MS.SQLSVR.v9.en/udb9/html/9a2405f2-80bc-4748-a019-ac644356d3e7.htm

SQL2K:

ad_impt_bcp_33z9.htm (Copying Data from a Query to a Data File)

Or Google for BCP and xp_cmdshell.

Good luck!

Phil H.
Some Bank
-----------
Time's fun when you're having flies.
 
You can also create a dts file and call that from inside a stored procedure, that way you get your column headers as well.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top