Sra1K
Sra1K

Reputation: 13

Azure Data Factory Dynamic content parameter

I am trying to load the data from the last runtime to lastmodifieddate from the source tables using Azure Data Factory.

this is working fine :

@concat(' SELECT  * FROM dbo. ',
        item().TABLE_list ,
       ' WHERE   modifieddate > DATEADD(day, -1, GETDATE())')"

when i use:

@concat(' SELECT  * FROM dbo.  ',
         item().TABLE_list ,
        '  WHERE   modifieddate > @{formatDateTime(
                  addhours(pipeline().TriggerTime-24)),
                  ''yyyy','-','MM','-','ddTHH',':','mm',':','ssZ''}')

getting error as ""errorCode": "2200",

"message": "Failure happened on 'Source' side. 'Type=System.Data.SqlClient.SqlException,Message=Must declare the scalar variable \"@\".,Source=.Net SqlClient Data Provider,SqlErrorNumber=137,Class=15,ErrorCode=-2146232060,State=2,Errors=[{Class=15,Number=137,State=2,Message=Must declare the scalar variable \"@\".,},],'",
    "failureType": "UserError",
    "target": "Copy Data1"
}

Upvotes: 0

Views: 5282

Answers (1)

Fang Liu
Fang Liu

Reputation: 2363

    SELECT * 
    FROM dbo.@{item().TABLE_LIST} 
    WHERE modifieddate > 
    @{formatDateTime(addhours(pipeline().TriggerTime, -24), 'yyyy-MM-ddTHH:mm:ssZ')}

You could use string interpolation expression. Concat makes things complicated.

https://learn.microsoft.com/en-us/azure/data-factory/control-flow-expression-language-functions#expressions

Upvotes: 2

Related Questions