dbTalk Databases Forums  

DTS Export SQL to Multi-Sheet Excel

microsoft.public.sqlserver.dts microsoft.public.sqlserver.dts


Discuss DTS Export SQL to Multi-Sheet Excel in the microsoft.public.sqlserver.dts forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
AT
 
Posts: n/a

Default DTS Export SQL to Multi-Sheet Excel - 05-18-2006 , 11:46 AM






This is a general inquiry for help. I have two separate projects where
I am exporting multiple sets of data to Excel documents, and it would
be easier for me to be able to do it all within one Excel document,
using separate Sheets for the separate data sets.

Currently I have something in development that works like this:

In my current project, I need to generate Assignment Forms for
Terminals and each Stand within a Terminal should either have its own
Excel document or ideally their own Excel Sheet within a Terminal
document.

A stored procedure cursors through the Stands(Stores) for a given
Terminal, and I have a DTS that can create a Sheet in Excel, then
rename that Sheet to the name of the Stand. In theory, I should then
be able to open that document again and do the same procedure for the
next Stand by creating a new Sheet and then renaming it, but I continue
to have problems. For each Terminal there is a variable number of
Stands, so it is better to cursor through this then creating a static
procedure. Excel create statements are very picky so I cannot create
the table/sheet with the Stand name, I have to create it with a generic
name then rename it. This seems to be the root of my problems. If I
create the first sheet "Stand1", fill the sheet with data, then
rename it to the stand name like "A-29" then when it comes to the
next stand in the cursor, it tries to create a new "Stand1" sheet
but says it already exists. So I try to delete it before creating it,
and it says that it was deleted, then it can supposedly create a new
"Stand1" sheet, but instead it just clears the last sheet I created
and then fails on the sheet rename.

Does anyone have any ideas on how I can accomplish this? Has anyone
done something similar and there is an existing procedure I could mimic
or learn from? Has anyone even tried this before or am I treading in
new territory?

If I have to, I could just create a number of Excel documents instead
of this one document with multiple sheets, I just thought it would be
easier to manage one document instead of many.

I thank you in advance for your help and your time taken to read and
consider this. If there are any questions please let me know.

Thanks,
Matthew Van O'Linda
Programmer Analyst ~ Delray Beach, FL


Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.