To copy dynamically all the tables of schema='Sales' from SQL server to datalake storage, you can take the lookup activity which retrieves the all the required tables and then take the for-each activity and inside the for-each activity, take the copy activity to copy each table that are listed in lookup activity output. Below is the detailed approach.
- Take the lookup activity with SQL Server dataset. Select the
query
option from theuse query
options. Give the query as
SELECT table_name
FROM information_schema.tables
WHERE table_type = 'BASE TABLE' and table_schema = 'SALES'
The above query will give the table names where schema is 'SALES'.
- Then take the for-each activity and connect it with lookup activity on its success. In the settings of for-each activity, give the expression for items as
@activity('Lookup1').output.value
. This expression will return the value of previous lookup activity output as array.
- Then inside for-each activity, add copy activity. In source settings of copy activity, add SQL Server dataset. In dataset connection, add the file name
@item().TableName
as dynamic content.
Similarly in the sink settings, add the datalake gen2 delimited dataset. In sink dataset connection, add the folder and file name @item().TableName
as dynamic content.
This way, you can copy dynamically all the tables to destination container.