I faced with the issue when I tried to pass datetime parameter from pipeline to dataflow stored procedure.
I've using stored procedure for getting full or incremental dataset.
First I tried to define input parameters as datetime2, but I found article that datime2 not supported and denifition of my stored procedure looks like this
CREATE PROCEDURE [dbo].[Export]
@LoadStartDate VARCHAR(30) = NULL,
@LoadEndDate VARCHAR(30) = NULL
AS
DECLARE @error VARCHAR(200) = NULL
IF (@LoadStartDate IS NULL AND @LoadEndDate IS NOT NULL) OR
(@LoadStartDate IS NOT NULL AND @LoadEndDate IS NULL)
SELECT @error = 'Parameters @LoadStartDate and @LoadEndDate should be specified.'
IF @LoadStartDate IS NOT NULL AND TRY_CAST(@LoadStartDate AS DATETIME2(3)) IS NULL SELECT @error = 'Parameter @LoadStartDate is not a date.'
IF @LoadEndDate IS NOT NULL AND TRY_CAST(@LoadEndDate AS DATETIME2(3)) IS NULL SELECT @error = ' Parameter @LoadEndDate is not a date.'
In stored procedure I use logic to implement full or incremental load using dynamic sql. SP works well on azure sql server.
My pipeline looks following
In lookup I check last modified date to know shall it be full or incremental load.
I passed to dataflow 2 parameters, that defined there as a string.
expressions have the following code:
LoadStartDate @activity('GetLastLoadData').output.value[0].LastLoadedDate
LoadEndDate @if(equals(activity('GetLastLoadData').output.value[0].LastLoadedDate, null), null,pipeline().TriggerTime)
In data flow I've try to setup stored procedere call
Utilizing expressions
LoadStartDate iif(length($LoadStartDate) > 23,left($LoadStartDate, 23),toString(null()))
LoadEndDate iif(length($LoadEndDate) > 23,left($LoadStartDate, 23),toString(null()))
The goal of above expression get string in format '2021-01-25T13:56:56.952'
Diring dubug it seems that parameter values are ok
but dataflow failed
Does anyone have an idea what is wrong? Any ideas appreciated.