I have to delete excel file to avoid appending to file.

  • Hi,

    I am writing a report to an xls file from a sql server table. I want to delete the existing xls file that I am going to write to or to "drop" it would be best.

    I was able to do this when doing a transformation between txt to excel, but am not having luck droping the xls file now.

    Anybody know the way to do this?

     

    Very appreciated,

    Mike

  • are you using vb ?! does kill fileName not work ?!







    **ASCII stupid question, get a stupid ANSI !!!**

  • Actually, it is a pretty simple confection at this point, just a copy column report from my dynamicly built table.

     

    I had success though, using the table name of the connection to the xls file, and dropping it with that.

     

    thanks for input.

    -Mike

  • The drop table name method that I was using only seemed to work for a couple of times. then the dts didn't like it and totally refused to work well at all.

     

    How might I employee this kill file method through an exclusive procedure. that is, I would like to kill a specific file, then run my dts functions which create a table, copy info from a sql table and post that data into a xls file.

    I just need to kill the xls file before the copy or else I am appending records where I need an exclusive data set.

     

  • what syntax were you using for "drop table..." and why do you say that the dts didn't like it...did you get any error messages ?!?!

    If you post your code, someone may be able to help you out!







    **ASCII stupid question, get a stupid ANSI !!!**

  • You might try adding an ActiveX Script object to the DTS and using FSO (FileSystemObject) like below...

    Set fso = CreateObject("Scripting.FileSystemObject")

    Set fileObject = fso.GetFile("yourfile.xls")

    fileObject.Delete

    Set fileObject = Nothing

    Set fso = Nothing

  • See this article I posted a while back:

    http://www.sqlservercentral.com/forums/shwmessage.aspx?forumid=19&messageid=187740#bm187760


    ------------------------------
    The Users are always right - when I'm not wrong!

Viewing 7 posts - 1 through 6 (of 6 total)

You must be logged in to reply to this topic. Login to reply