SSIS doesn't drop table

  • I have a T-SQL Statement Task to create table every time the package run. It doesn't return error but it doesn't drop the table either. The data is appended every time. The code is working fine in SQL server query window. Can you see what is wrong in the code below? TIA

    IF OBJECT_ID (N'M020_Vendor', N'U') IS NOT NULL

    DROP TABLE M020_Vendor

    GO

    SET ANSI_NULLS ON

    GO

    SET QUOTED_IDENTIFIER ON

    GO

    CREATE TABLE [M020_Vendor]

    ( list of fields

    )

    GO

  • 1) Have you checked that the statement is running in the right database?

    2) Why not truncate the table rather than drop/create?

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

  • Code seems fine - have you inadvertently disabled that script task? Possibly just running the subsequent inserts resulting in appended data?

  • Quick thought, schema qualify the table name by adding the schema name + dot prefix.

    😎

  • check SQLAgent account permissions

  • Thank you for all the replies.

    The code was working in SQL query.

    I wanted to drop the table because the table schema may change so I only need to update it in this package and don't need to open up SQL server to delete the table.

    I took me many days to find out that the T-SQL statement task connection wasn't connected to the database I want it to create table so I have been drop and create table in master database. I didn't check this connection as I thought I had it set up correctly.

  • ____ KD (5/7/2015)


    Thank you for all the replies.

    The code was working in SQL query.

    I wanted to drop the table because the table schema may change so I only need to update it in this package and don't need to open up SQL server to delete the table.

    I took me many days to find out that the T-SQL statement task connection wasn't connected to the database I want it to create table so I have been drop and create table in master database. I didn't check this connection as I thought I had it set up correctly.

    This is normally referred to as the <Head><Desk> loop:-D

    😎

  • It was also the first question in the first response!

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

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

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