简体   繁体   中英

load all databases from the source to ADLG2(azure data lake gen2)

is there a way to load all databases from the source SQL Server to the data lake as it is?

I tried to load each database with his tables but I am asking if there was a way to load all databases as it is to the data lake

One of the ways to load all databases from SQL to ADLG2 is by using Azure Data Factory

Follow the below procedure to load all databases from SQL to ADLG2:

  1. First create one pipeline and take script activity in it add linked service with master database select script as Query And give the following query:
    SELECT name, database_id, create_date  
    FROM sys.databases;

在此处输入图像描述

  1. Then take ForEach activity and int its settings give Items as so it will fetch output of script activity
    @activity('Script1').output.resultSets[0].rows

在此处输入图像描述

  1. In for each activity take one lookup activity, create and add linked service for database with dynamic values

在此处输入图像描述

In that dataset add Db name parameter

在此处输入图像描述

Noe send this parameter value to linked service properties as below

在此处输入图像描述

Lookup activity settings

SELECT table_Schema, TABLE_NAME, TABLE_CATALOG
FROM information_Schema.tables
WHERE TABLE_TYPE =  'BASE TABLE'sql

在此处输入图像描述

  1. now take execute pipeline activity click on new in that pipeline create lookupOP parameter with array datatype and in execute pipeline pass the value to it as output of lookup as @activity('Lookup1').output.value

在此处输入图像描述

在此处输入图像描述

  1. In that new pipeline take ForEach activity and passthe parameter we created as items

在此处输入图像描述

  1. In that for each activity take one copy activity and for the source dataset create linked service on SQL database with dynamic values as we created previously

在此处输入图像描述

In this dataset create parameters for database name, table name and schema name

在此处输入图像描述

now add these dynamic values to linked service properties and Table name, table schema

在此处输入图像描述

Copy activity source setting:

在此处输入图像描述

create parameters in sink dataset

在此处输入图像描述

now add these dynamic values to folder name, file name

在此处输入图像描述

Copy activity Sink settings

在此处输入图像描述

Output

creating folder of database name and in that folder loading tables of that particular database

在此处输入图像描述

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM