How to Create a dynamic table in SQL Server from excel file and insert the data in the table

I have an excel sheet

The table name should be the sheet name. And all the data of excel file have to be inserted into the table.

And my excel file will be dynamic. Always the sheet name is not same.

Can anyone help me on this

is it only the sheet name that will differ? What about number of columns?

If only the sheetname is dynamic. Refer this post.

Regards,
Sruthi YNM

Hi @ynm_Sruthi, I need to create a data table using the excel data in sql server. And the table name should be the sheet name.

Manually for creating the data level we use below
Create Table Table name( Name varchar(25)).

In the same way I need to create a table in sql like this
Create Table Sample ( number varchar(32) , name varchar(32),….)
How could I can create table with data in excel sheet dynamically in sql server using uipath.

And the post you shared is related to get the sheet name.

Read the Excel sheet into a datatable using Read Range, also get the sheet name using Get Workbook Sheets (inside Excel Application Scope).

Use the sheet name and column names yourDt.Columns (array) to build a SQL statement. Then use Execute Non Query to send the SQL statement to SQL server to create the table.

Then you can use Bulk Insert (in UiPath.Database.Activities dependency) to write the data to the SQL table.

1 Like

You can take a look here

Cheers