Skip to main content
mk0724
September 18, 2024
Solved

Import Excel to different tables in database

  • September 18, 2024
  • 10 replies
  • 0 views

Hi all,

I have a requirement of importing the excel file to database. When the user upload an excel file in import it should create new data in 3 different tables.

For example, in the excel file the data present is based on deals and each deal can have one or more number of loans and the deal will be having some amount values. So when the user upload a file it should update deals table, loans table an other table which contains of amount data of the deal.

Thank you.

Best answer by somasundaram.d

As said in your other discussion post.

Please change all the columns in the database table to varchar() then the import will succeed. And you will have all your data from excel in the staging table as text. Then you can manipulate the data as per your need.

10 replies

gayathris111098
September 18, 2024

We may need to use a two-step process for this requirement:

1. **Upload to a Staging Table**: First, when the user uploads the Excel file, the entire data can be written to a temporary staging table. This ensures that the raw data from the Excel file is captured in a structured manner without directly affecting the main tables. Any validations or initial transformations can also be performed here.

2. **Populate Data to Main Tables**: After the data is in the staging table, we can read the relevant information and populate the required main tables—such as the *deals* table, *loans* table, and a separate table for the deal amount values. The necessary business logic to relate deals and loans should be handled in this step.

3. **Clear Staging Table**: Once the data is successfully written to the main tables, the staging table can be cleared, ensuring it's ready for the next upload 

mk0724
mk0724Author
September 19, 2024

Okay

Thank you.

September 18, 2024

use 'Parse Excel to CDT' smart service. Map corresponding columns from excel into the table CDT you have , check relationships and insert or update data. 

mk0724
mk0724Author
September 19, 2024

Okay will try.

Thank you.

somasundaram.d
September 18, 2024

One other approach would be to import the excel data in a temporary staging table and using a stored procedure to update the related tables