Azure Data Factory concating syntax - azure

I'm trying to run a pipeline that results a select with where be the system triggername system output.
I've tried to use :
#concat(concat(concat(concat('select * from ',item().DB_CARGA,'.',item().SC_CARGA,'.',item().tb_carga, 'where ' ,item().DS_CARGA ,'=', string(pipeline().TriggerName)))))
But I'm getting the following error:
Could anyone help me with the right syntax?

I reproduced this and got similar error when I used your syntax.
In your dynamic expression, there should be a space between table name and where and also trigger name should be enclosed in single quotes.
Please go through the below procedure to resolve the error.
First, I have a lookup activity which will give database name, table name and SQL table column(trigger column name). Give this to Foreach.
I have created sample tables with trigger_column column and gave some values.
In pipeline I have created trigger with same name mytrigger. Inside Foreach for my demo I have used lookup query. You can use your activity as per the requirement.
Dynamic content:
You can do this with single concat function.
#concat('select * from ',item().database,'.',item().table_name, ' where ' ,item().trigger_name ,'=','''',string(pipeline().TriggerName),'''')
This will give the SQL query like this when Executed.
Output when triggered:

Related

Column resource not found

I want list orphaned disk on my Azure but in the result I obtain this message :
'where' operator: Failed to resolve table or column expression named 'Resources'
I have taken the kql from internet and everybody use Resource has column to get result , I want to know why in my azure there is this error;
The column has the name changed ?
Thanks
Your workspace (or database) does not have a table or function called "Resources", you need to check the table list in the connection pane and see the tables you have, here is an example:

querying of SQL table with dynamic date filter in Azure data factory (Azure synapse analytics)

How to pass datetime parameter to a SQL query in a source of the data flow activity in ADF/synapse analytics?
I am building a synapse analytics pipeline that performs a delta load in a fact table. First, the table is queried with a lookup activity to get the latest LoadDate value. The returned value is then set as a variable and passed as a parameter to a data flow activity.
I am struggling to get the data flow running properly. I have tried to concatenate the SQL query with the filter value in the 'SetVariable' activity but get 'The store configuration is not defined.' error. Same happens when I pass only converted LoadDate value to the source query in data flow activity:
"SELECT top 10 * FROM dbo.facts WHERE timestamp > #pipeline().parameters.LastLoadedDate"
After many try-and-error attempts, this syntax worked for me:
concat("SELECT * FROM dbo.facts WHERE timestamp > CONVERT(datetime2, '" , $LastLoadedDate, "')")
the key was to use double quotes to wrap concatenated strings...
Please try this SQL:
concat('select top 10 * FROM dbo.facts WHERE timestamp >', $yourParameterName)
In data flow, you can't use pipeline expression like this #pipeline().parameters.LastLoadedDate, you should use the parameter value in data flow.

Azure Data Factory passing a parameter into a function (string replace)

I'm trying to use ADF to create azure table storage tables from one source SQL table.
Within my pipeline..
I can query a distinct list of customers pass this into a for-each
task.
Inside the for each select the data for each customer
But when I try to to create an Azure table for each customers data with the table name based on the customer ID I hit errors.
The customer ID is a GUID so I'm trying to format this to remove the dashes which are invalid in a table name...
Something along the lines of
#replace('#{item().orgid}','-','')
So 7fb6d90f-2cc0-40f5-b4d0-00c82b9935c4 becomes 7fb6d90f2cc040f5b4d000c82b9935c4
I can't seem to get the syntax right
Any ideas?
try this: #replace(item().orgid,'-','').

Data Parameter in Excel not working with Access Query Connection

I have a connection to an Access DB query within Excel. The field in the Access query is an expression turning a field into a proper date. The problem that I'm having in Excel lies within passing the parameter from a cell containing the date that I want the query to run for. The results are either completely wrong or result in nothing. I have tried modifying the parameter cell to just about everything to no avail. I have tried the edit query option under view connection and when prompted to put in the value for the parameter, it actually returns the data I want. I would thing that this would be exactly the same parameter it would be grabbing from the formatted cell?
I have attached my connection's SQL command text below. And also an image with more detail and screenshots.
This is the command text from Excel containing my Where clause:
SELECT Query1.SETYPE, Query1.`SEORD#`, Query1.ORBILL, Query1.ORCUST, Query1.ORLDAT,
Query1.ORCONS, Query1.SESEV, Query1.CMTYPE, Query1.CMTEXT, Query1.ORDDATfix
FROM `C:\USERS\DRED\DESKTOP\ServiceFailures.accdb`.Query1 Query1
WHERE Query1.ORDDATfix =?
SELECT Query1.SETYPE, Query1.`SEORD#`, Query1.ORBILL, Query1.ORCUST, Query1.ORLDAT, Query1.ORCONS, Query1.SESEV, Query1.CMTYPE, Query1.CMTEXT, Query1.ORDDATfix
FROM `C:\USERS\DRED\DESKTOP\ServiceFailures.accdb`.Query1 Query1
WHERE (Query1.ORDDATfix>=?)
Apparently putting the clause in parenthesis fixed the problem.

ssis string variables value should be used in exequte sql task

I am trying to create a table. In the table name id is unique
(MARKET_id is the name of the table).
The id has leading zeros which needs to be preserved. So I declared id as a string variable.
Example: id=02161515. And in parameter mapping I mapped it as VARCHAR.
An error occurs when I'm using a sql statement CREATE TABLE MARKET_?;. It results in: CREATE TABLE MARKET_'02161515'; the quotes is unnecessary and throws an error found "'" in the sql statement.
Please help!
I guess you have columns added to your table, but are not posted?
One way to solve this would be to create two variables, one for the table name and one for the create table statement.
Example (for demonstration only):
First variable is TABLE_NAME and defined with the following expression for demonstration of dynamic naming:
"dmu.MY_TABLE_"+(DT_STR,30,1252)datepart("s",getdate()) + "( id int)"
Second variable is CREATE_TABLE_SQL and defined as follows:
"Create table "+ #[User::TABLE_NAME]
Next change the Settings of your Execute_SQL_Task:
Set SQLSourceType to Variable and SourceVariable to User::CREATE_TABLE_SQL
This will create the table in your database

Resources