I have data in excel sheet which I am reading in a datatable and then trying to insert into sql table on sql server. I can upload the data into sql table but the order of data rows in not correct to what I have in my datatable or in excel sheet.
I checked the order of rows in the input data of sql insert query which is correct but somehow it is inserting rows randomly in sql table. Any help in this regard?
—once after the datatable been fetched from excel it will obviously have the same order of rows as in excel
But still let’s confirm that first with these two activities
—use a OUTPUT DATATABLE ACTIVITY and pass the dt variable as input and get the output as string variable named str_dt
—and then use a writeline activity and mention the str_dt as input
—now output panel will show the data and you can check the order of rows in it
And pls clarify how the data is inserted
Can we see the query if possible @WASEEM_KHAN
I am not using any sql query command. I am using UIPath activity for it i.e. UiPath . Database . Activities . InsertDataTable. So, I am getting wrong order on my SQl table due to this activity.
Whilst it is odd for the data to not be in order, SQL tables shouldn’t rely on any kind of order. If you are needing your data to be in a specific order then I dare say you have bigger problems, perhaps you should reconsider your data structure. As long as all you data gets in I wouldn’t overthink it.
I just want to be my data in the same order as I have in my datatable but I think, this is not the case with Sql as it does not maintain the same order of rows as you just said as per my understanding.
Yeah, I’m saying thats the wrong mindset to have, especially in a raw table.
SQL server is built upon the assumption you will design in with relational data principles in mind which do not require the data to be in any specific order.
If you aren’t familiar with relational database design I’d strongly urge you to take a step back before using SQL Server and have someone who knows that stuff to help you with your data.