Execute multiple sql statements in the ADF without batch script and stored procedure

Mahima Lalwani 1 Reputation point
2021-02-06T08:19:36.21+00:00

Recently, I have been tangled to a situation where I am neither allowed to use the batch service for executing python scripts nor to execute stored procedure.

The pipeline which I am trying to achieve is: Blob --> Staging --> Some SQL transformation --> Loading into final target table into the Snowflake

Dummy SQL: TRUNCATE TABLE CDWD.USERS.EE_NEW_LAUNCHES_MAST command 1

INSERT INTO Table 1 command 2

(

some fields

)

WITH CTE AS

(

SELECT CYAGG.TIME_PERIOD_NO,

field1, field2, derived field 1, computed field 2, transformed field 3 (example Substring (Table2.field1,1,20) etc

From AnotherTable
Join AnotherTable2

) Select * from CTE;

select 1 as id; (If this was lookup activity)

Would really appreciate the help.

Azure Data Lake Storage
Azure Data Lake Storage
An Azure service that provides an enterprise-wide hyper-scale repository for big data analytic workloads and is integrated with Azure Blob Storage.
1,559 questions
Azure Data Factory
Azure Data Factory
An Azure service for ingesting, preparing, and transforming data at scale.
11,623 questions
{count} votes

1 answer

Sort by: Most helpful
  1. HimanshuSinha-msft 19,486 Reputation points Microsoft Employee Moderator
    2021-02-08T22:07:15.837+00:00

    Hello @Mahima Lalwani ,
    Thanks for the ask and using the Microsoft Q&A platform .

    I think the intend is by using ADF but before you run the select query for lookup you want to get some other things done and one of them is to truncate a table also .

    -- Data prep
    CREATE TABLE to_be_trucated
    ( id int )
    INSERT INTO to_be_trucated VALUES(1)

    -- You are trying this
    Truncate table to_be_trucated
    GO
    with CTE AS
    (
    select colB,ColC from [dbo].[someothertable] )
    Select * from CTE

    You can use the lookup activity and use the query option and add the below script

    Truncate table to_be_trucated ;
    with CTE AS
    (
    select colB,ColC from [dbo].[someothertable] )
    Select * from CTE

    65538-adf-issue.gif

    Thanks
    Himanshu
    Please do consider to click on "Accept Answer" and "Up-vote" on the post that helps you, as it can be beneficial to other community members

    0 comments No comments

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.