Search code examples
azure-data-factory

How to Get Azure Data Factory to delete a field before send a table to Sink Without using DataFlows


Is it possible to get ADF to delete a field in a table before it is sent to Sink location?

For example if I have a Lookup activity that discovers a field in a table is it possible to for the copy activity to delete that field in the table before sending the table to sink?


Solution

  • You can add the below sql script in the pre-copy script in the sink settings of copy activity:

    IF EXISTS (SELECT 1
               FROM   INFORMATION_SCHEMA.COLUMNS
               WHERE  TABLE_NAME = 'Table1'
                      AND COLUMN_NAME = 'col1'
                      AND TABLE_SCHEMA='Schema1') 
    BEGIN
      ALTER TABLE Table1
        DROP COLUMN col1
     END