Insert data table Column contains space to SQL server

I am getting an error while inserting data form excel to SQL server using Insert activity in Uipath as the Column name of excel contains space. Please help me to insert data without removing space from the Column name.

@Sweta_Chaurasia

give a try on surounding column name with ’ like

grafik

Hi Peter. Thanks for your reply. But I am using Insert database activity in uipath. And I am try to insert data from excel sheet to SQL server. Is it possible to insert data to SQL server without removing space form the column name?

had you tried to surround the Column name with ’ ?

Hi Peter, First I have use read range activity and store the data in a data table after that I am using Insert activity to insert data in SQL server. Here where I can surround the column name like this ’ column Name’?

in general it is advisable not to have space in column name

so what is the exact name from database datacolumn structure for a column with space in name?
you can try to change the datatable (this one from read range) by
yourdtVar.Columns(“ColNameOrIndex”).ColumnName = “NewName”

and bring it into a form that it is matching the name from database

Yes, I know that it is not advisable to have space in column name. But it is my requirement to automate the task. Previously the excel sheet was inserted using SQL server Import and it allows space in column name. So now I can’t change the column name format. Searching for an alternate option so that I can insert data without removing space.

@Sweta_Chaurasia
as you can modify the datacolumn names from datatable (output from readrange) you have a chance to RnD it. This was mentioned above. Typically surroundings can be ’ or [

otherwise have a look here:

1 Like

Thanks for your efforts. I am working on the code.