SSIS drop table on spreadsheet

  • Hi There pls assist.

    I am trying to create a package that will query sql server and return results to excel, this package should replace existing data on the excel with new data everytime it runs.

    currently I tried using two sql tasks one to drop the table and one to create. when I run the drop table task it only clears the headings.

    please assist.

    Kind Regards

  • How about TRUNCATE TABLE or DELETE * FROM TABLE ?

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • If all of the data on all of the tabs in the file are refreshed each time, you might consider dropping and recreating the excel file with each run.

  • You could also create a "template" so to speak, with the necessary tabs with column headers only, from the resulting spreadsheet, and copy it over the exsting spreadsheet each time in a prior step.

    Steve (aka sgmunson) 🙂 🙂 🙂
    Rent Servers for Income (picks and shovels strategy)

  • I agree with sgmunson. Back in the day when I did alot of DTS work, both the truncate table and delete from table would work fine. The syntax for the name of the tab was a little weird. Just google around.

    Good luck

    John Miner

    CraftyDBA

    http://www.craftydba.com

    John Miner
    Crafty DBA
    www.craftydba.com

  • Hi Guys,

    I tried delete * from table_name, but I get this error :

    [Execute SQL Task] Error: Executing the query "delete * from Data_Destination" failed with the following error: "Deleting data in a linked table is not supported by this ISAM.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

    I tried truncate table table_name, but I get this error :

    [Execute SQL Task] Error: Executing the query "truncate table Data_Destination" failed with the following error: "Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.". Possible failure reasons: Problems with the query, "ResultSet" property not set correctly, parameters not set correctly, or connection not established correctly.

  • The Excel SQL syntax (or whatever it is called) is more like this:

    DELETE * FROM [mySheet$]

    Need an answer? No, you need a question
    My blog at https://sqlkover.com.
    MCSE Business Intelligence - Microsoft Data Platform MVP

  • Thanks for the feedback I went with deleting and recreating the file and it worked fine. thanks everyone

  • I know this post is old, but for anyone stumbling onto the forum looking for a way reset the "Name of Excel sheet" inside of the Excel Destination - you cannot use DROP TABLE [tableName$];.  What you have to realize is that the CREATE TABLE statement you made by clicking "New..." actually created a spreadsheet at the destination.  You have to delete the spreadsheet before you on the file system/windows explorer before trying to recreate a new table.  This often happens when your first attempt uses the wrong Data Type in Excel, and you get the error "Cannot convert between unicode and non-unicode string data types".

Viewing 9 posts - 1 through 8 (of 8 total)

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