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)
 Outputing Resutls of SP to Excel

Author  Topic 

ucal
Yak Posting Veteran

72 Posts

Posted - 2009-01-21 : 19:53:02
Hi All,

I have a SP that process data and stores the results in a table
TableA.

My qustion is: How do I ouput the contents of this table to Excel within my SP.

CREATE procedure SpTableA
AS
SELECT * INTO TableA FROM TableX
--Will like to Write TableA to an Excel File.

Any assistance will be welcomed.

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2009-01-21 : 19:55:02
You can use Openrowset,Opendatasource,Linked Server or SSIS for it.
Go to Top of Page

ucal
Yak Posting Veteran

72 Posts

Posted - 2009-01-22 : 07:39:20
I have not used Openrowset before , can somebody point me in the right direction.
Go to Top of Page

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2009-01-22 : 07:47:26
Should be some stuff like this:

insert into OPENROWSET('Microsoft.Jet.OLEDB.4.0',
'Excel 8.0;Database=c:\yourexeceldestinationfilename.xls;',
'SELECT * FROM [worksheet$]') select * from TableX


You can search for openrowset in this forum...

Webfred


No, you're never too old to Yak'n'Roll if you're too young to die.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2009-01-22 : 07:48:55
More details
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926

Madhivanan

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

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2009-01-22 : 09:22:13
http://sqlblogcasts.com/blogs/madhivanan/archive/2007/08/27/import-export-to-excel.aspx
Go to Top of Page
   

- Advertisement -