Need help learning how to use Database Insert Activity

Hi everyone,

I am trying to use the Database Insert activity to insert a tab delimited text file into a database table on Microsoft SQL Server.

  1. I first click the Configure Connection button within the Insert Activity in UiPath.

  2. I click on the Connection Wizard button to establish my connection to the database.

  3. I enter my Server Name, click “Use Windows Authentication”, and select my table. I click Test Connection and it can connect successfully.

  4. This brings me back to the Insert activity but with the connection configured. The data I am trying to insert into the table is a tab delimited .txt file on my computer. How do I insert that into the activity?

1 Like

I am attaching some dummy data which resembles the structure of what I am currently using.
RPADummyData.txt (2.2 KB)

Usually INSERT activity takes in datatable as input
—as we have txt file with tab delimited use
READ TEXT FILE ACTIVITY and pass the file path of that txt file as input and get the output with a variable of type string named str_output
—now use a GENERATE DATATABLE ACTIVITY and pass the variable str_output and get the output variable of type datatable named dt
—now mention this dt variable as input in INSERT activity
Cheers @hall1570

This solution is simple, elegant, and so close to working. I am getting the error: Invalid column name’Column1’ and so on.

I am attaching a screenshot of my workflow below.

I don’t understand why i’m getting this error because I configured my column headers in SQL server to match my TAB file column headers. Below I am attaching a screenshot of my column headers and data types.

Under my Generate Data Table activity, I selected the following options:

By doing this, I am only getting the error: “Insert: Incorrect syntax near ‘Month’.”

Kindly check whether there USA y space or any special characters next or before to that word Month

No special characters. I am attaching my .xmal below. I am now getting the error: Insert: Incorrect syntax near’Date’.

UploadDatabase.xaml (5.6 KB)

In that .xmal, the Execute Non Query activity deletes the existing data from the data table.

Then the Read Text File reads the tab delimited text file and outputs it into a variable.

The Generate Data Table activity generates a data table from the output from “Read Text File”.

Then the Insert to Database activity should insert the generated data table into the SQL data table which I deleted from.

Figured it out, my activity didn’t like the spaces I had between column names. I replaced them with an underscore and it works.

Cheers @hall1570

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.