Importing Json Dataset To Sql Server With Ssis

 

Data transfer between API (Application Programming Interface) and databases is a frequently used method in many applications. This process ensures that the data presented by the API is saved in the database or the data retrieved from the database is used by the API. Here, after setting up the necessary configurations, we will talk about how to transfer the JSON response to the database. Before starting the process, make sure that you have created the table according to the variables in the JSON file.

First of all, we drag and drop a Data Flow Task in our newly opened Package.

We place the Script Component in it which is located in the Common tab in the SSIS Toolbox. We click on Script Component and we will mark the Source on the screen that appears.

Right click on Script Component and click on Show Advance Editor. Click on the Input & Output Properties section, in the section that appears, we add all the columns in the JSON file to the Output Columns, do not forget to edit the data type section in each variable.

After completing the process, click Edit from Script Component.

We need to add reference from Solution Explorer, and for this we click add references from reference.

We add system.web.extensions. You can find it quickly by searching.

Now, we will deserialize our data. For this we need to add Class. We give a name by selecting the add new item option from the Properties, then the Class.

This will add an empty class to our script, here we write our columns in C# language. First we write our data type, then the variable name, then the parameters in square brackets. Don't worry, you can do this easily even if you don't know C#. As an example, we leave a piece of code here.

After the process is complete, we return to the main.cs script, the piece of code shown below will be pasted in the section starting with public override void.

In your own cases,

  1. Do not forget to write the names of your columns in the section starting with Output0Buffer.

  2. Write your reference in the section starting with List.

  3. Give the Path of the Json file in the line starting with File.ReadAllText

Some classes may not be readable, you will need to define for this, move your mouse to the marked areas and click Show potential fixes, select the 1st suggestions.

When you hover over it, you will receive a notification like this.

Then you can use suggestion 1 as in the image below.

Possible necessary definitions are highlighted. After it is defined, it will be written in color as on the screen.

Exit the script, click Ok to save the changes.

Drag and drop OLE DB Destination, then make the necessary configurations and connection.

You can see the OLE DB Destination connection configurations below:

After the process is complete, run your Package.

General 2023-01-17 15:17:21

Data Warehouse Theory To Practice - Intro

The importance of data and reporting in today's world is known, in this article we will look more at the concept of data warehouse, which facilitates data reporting and provides us with a lot of convenience in terms of data.

General 2023-01-27 13:40:54

Overfitting In Machine Learning: Understanding And Avoiding It With Effective Techniques

Overfitting is a common problem in machine learning, where a model performs well on the training data but fails to generalize to new, unseen data. In other words, the model has learned the training data too well, and as a result, it fails to capture the underlying patterns in the data.

Machine Learning 2023-04-19 13:23:23

Effect For Powerbi

Data visualization is a powerful tool for understanding complex data and making informed decisions. By transforming large amounts of information into a graphical form, data visualization helps individuals and organizations better understand trends, patterns, and relationships in their data. There ar...

Other 2023-03-24 14:27:21

Data Warehouse Theory To Practice - Intro

The importance of data and reporting in today's world is known, in this article we will look more at the concept of data warehouse, which facilitates data reporting and provides us with a lot of convenience in terms of data.

General 2023-01-27 13:40:54

Get Notifications When We Share New Stories