• Scott In Sydney - Friday, July 21, 2017 8:43 AM

    My actual question is resolved, but for completeness...

    I will create the below SP:

    ALTER PROCEDURE sp_DropTable (@tableName VARCHAR(255))
    AS
    BEGIN
      DECLARE @SQL VARCHAR(1000);
        SET @sql='BEGIN TRY
        IF EXISTS(
            SELECT 1 FROM sys.objects WHERE OBJECT_ID = OBJECT_ID(N''{0}'') AND type = (N''U''))
            BEGIN
                DROP TABLE {0}
                PRINT ''{0} dropped.''
            END
        ELSE
            BEGIN
                PRINT ''{0} does not exist.''
            END
    END TRY
    BEGIN CATCH
        PRINT ''Error dropping {0}''
    END CATCH
    '
        SET @sql=REPLACE(@sql,'{0}',@tableName)
        --PRINT @SQL;
        EXEC (@SQL);
    END

    Then in SSDT I will code my Execute SQL Task as:exec sp_DropTable ?

    and map my tableName variable to Parameter 0.

    Thanks for the help.

    Glad to see that you got a working solution, how ever, I would use caution with that particular one. You could easily suffer  SQL injection from that particular SP. For example, what if use used the ta let name;
    Test; CREATE DATABASE [YourNewDB];
    I suspect that would you'd  have a nice new DB on your server.

    Thom~

    Excuse my typos and sometimes awful grammar. My fingers work faster than my brain does.
    Larnu.uk