1

My pipeline should first check whether the table exists or not.If exists it should drop the table and load the new table with same name.How can I acquire this requirement in my pipeline?

CHEEKATLAPRADEEP
  • 12,191
  • 1
  • 19
  • 42
arun
  • 19
  • 3
  • Does this answer your question? [how to execute sql script using azure devops pipeline](https://stackoverflow.com/questions/65885558/how-to-execute-sql-script-using-azure-devops-pipeline) – tymtam Jul 22 '22 at 11:02
  • 2
    @tymtam It probably doesn't. People confuse and mistag Azure Data Factory pipeline questions as `azure-pipelines` **all the time** because they don't read the tag description. – Daniel Mann Jul 22 '22 at 12:15

2 Answers2

0

Add script activity in your pipeline, give Query like if table exist in database drop that table.

IF OBJECT_ID('tablename', 'U') IS NOT NULL  
   DROP TABLE tablename ;  

enter image description here

To Auto create table with choice of your name:

Open the Copy activity >> Sink >> Dataset >> Table >> Edit >> Enter the name of the table that has to be generated, then under Sink >> Table option >> Select Auto create table to create table automatically, then run the pipeline.

The table will be crated automatically.

Refer: 'Script' activity in Azure Data Factory

Pratik Lad
  • 4,343
  • 2
  • 3
  • 11
0

2 ways to do it,

1, if you are using a dataflow, select recreate table option in sink settings.

  1. if you want to do it in the pipeline, add drop statement in pre copy script and select recreate option to automatically create table.
Hijesh V L
  • 191
  • 1
  • 5