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
 SSIS and Import/Export (2005)
 Export to excel (dynamic columns)

Author  Topic 

sonu
Posting Yak Master

110 Posts

Posted - 2008-09-25 : 10:13:43
Hello,

I need to export some data from a stored procedure that returns dynamic data with dynamic columns. I know the columns at run-time. How can I achieve this with a SSIS?

Thanks

sodeep
Master Smack Fu Yak Hacker

7174 Posts

Posted - 2008-09-25 : 10:23:43
You can use Execute SQL task and Excel destination Or Use OPENDATASOURCE or OPENROWSET.
Go to Top of Page

madhivanan
Premature Yak Congratulator

22864 Posts

Posted - 2008-09-25 : 10:59:09
Also refer
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=49926

Madhivanan

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

sonu
Posting Yak Master

110 Posts

Posted - 2008-09-25 : 13:47:23
I am looking at OPENROWSET:

EXEC sp_makewebtask
@outputfile = 'd:\testing.xls',
@query = 'Select * from Database_name..SQLServerTable',
@colheaders =1,
@FixedFont=0,@lastupdated=0,@resultstitle='Testing details'

Although I set the colheaders to 1, it doesnt export the header names. Any suggestions you can give me?
Go to Top of Page

sonu
Posting Yak Master

110 Posts

Posted - 2008-09-25 : 14:12:39
quote:
Originally posted by sodeep

You can use Execute SQL task and Excel destination Or Use OPENDATASOURCE or OPENROWSET.



I should be able to create the "create table task" dynamically, however I am not sure how to do the mapping between excel and the returned data.
Go to Top of Page

sonu
Posting Yak Master

110 Posts

Posted - 2008-09-25 : 14:28:27
I cant believe how much of pain this is...

I have been searching around for few hours.

OPENROWSET doesn't work, since we dont have excel installed on the server.
sp_makewebtask is able to export the data, however the result looks bad.
Any other options I can look at?
Go to Top of Page
   

- Advertisement -