|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Friday, May 18, 2007 3:36 PM
Points: 10,040,
Visits: 1
|
|
| Comments posted to this topic are about the Question of the Day for 17 Aug 2004 posted at http://www.sqlservercentral.com/testcenter/qod.asp?QuestionID=316.
|
|
|
|
|
SSChampion
        
Group: General Forum Members
Last Login: Friday, May 18, 2007 3:36 PM
Points: 10,040,
Visits: 1
|
|
| No one has responded to this topic yet. Even if you don't have a complete answer, the original poster will appreciate any thoughts you have!
|
|
|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Monday, September 03, 2012 11:06 AM
Points: 659,
Visits: 56
|
|
> You need to remove the existing data, > using the Excel automation model How to do that?
> copying a blank spreadsheet onto the target spreadsheet This is what I do, but I think it is a pretty primitive.
> executing a drop table, create table on your spreadsheet How to do that?
I would be really grateful, if someone could explain me how to use the 1st and the 3rd way of solving thsi problem.
|
|
|
|
|
SSC-Enthusiastic
      
Group: General Forum Members
Last Login: 2 days ago @ 5:10 PM
Points: 135,
Visits: 205
|
|
One way to do it is before doing the datapump task to load data to the workbook, set up an ActiveScript task.
Then, do some VBScript to
open Excel open the workbook select the right worksheet select the ActiveRange delete the ActiveRange. Save the workbook close Excel
Sorry I don't have the code off the top of my head right now, but you should be able to find some VBScript examples to do the bulk of it. Just google for it w/o specifying DTS, maybe something like: "VBScript Excel"
|
|
|
|
|
SSChasing Mays
      
Group: General Forum Members
Last Login: Monday, September 03, 2012 11:06 AM
Points: 659,
Visits: 56
|
|
Thanks a lot. I know how to code such a script.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Friday, January 07, 2005 11:54 AM
Points: 12,
Visits: 1
|
|
| Can someone expand on the drop table/create table method - does this have to be done using vbscript and the excel object model?
|
|
|
|
|
SSC Veteran
      
Group: General Forum Members
Last Login: Thursday, November 29, 2012 10:45 AM
Points: 248,
Visits: 14
|
|
If you use a data transformation task to populate the excel spreadsheet, your destination table name is your sheet name in excel. You can create an Execute SQL Task to perform the drop table (drop sheetname) from your excel datasource. Note: close the spreadsheet before executing this You then create the sheet with an Execute SQL Task to create the table (sheetname). You can get the code for this by going to your transformation destination tab and selecting create (it will pop up a window with the create table script). Copy this and paste it into your Execute SQL Task. Connect the tasks with workflow and you are ready to roll.
|
|
|
|
|
Grasshopper
      
Group: General Forum Members
Last Login: Tuesday, March 01, 2005 4:40 PM
Points: 13,
Visits: 1
|
|
| Actually, I just post to a .csv file. It opens in excel but replaces instead of appends.
|
|
|
|
|
SSCrazy
      
Group: General Forum Members
Last Login: Today @ 7:39 AM
Points: 2,100,
Visits: 1,791
|
|
|
|
|
|
Hall of Fame
       
Group: General Forum Members
Last Login: Monday, July 30, 2012 10:42 AM
Points: 3,434,
Visits: 519
|
|
Very good question! I actually have a similar job running. The business need in our case is to append data and I am using the export into Excel spreadsheet. Thanks everyone for your explanations, now I better understand why and how it works. Yelena
Regards, Yelena Varshal
|
|
|
|