# How to update sql table by passing value through variable

**URL:** <https://forum.uipath.com/t/how-to-update-sql-table-by-passing-value-through-variable/155628>\
**Category:** Help\
**Tags:** database, activities\
**Created:** [October 1, 2019, 12:00pm UTC](https://forum.uipath.com/t/how-to-update-sql-table-by-passing-value-through-variable/155628 "2019-10-01T12:00:49Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![DivyaT](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/divyat/32/68625_2.png) [@DivyaT](https://forum.uipath.com/u/DivyaT)\
**Post date:** [October 1, 2019, 12:00pm UTC](https://forum.uipath.com/t/how-to-update-sql-table-by-passing-value-through-variable/155628/1 "2019-10-01T12:00:49Z")

</div>

Hi all, Am reading data from Sql datatable and iterating for processing some action,In this i have assigned 1st column to variable and taking 2nd column value to perform action after completing the actions i have to update row status of sql datatable to completed status based on 1st column value but code is not giving any error but data is not updating in table.

This is my query: “Update midx\_table set Winesp\_Status=‘completed’ where ID=@cono”  
cono is assigned variable name

please can anyone help me out in this.

---

<div class="post-metadata">

**Author:** ![Palaniyappan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/palaniyappan/32/524095_2.png) [@Palaniyappan](https://forum.uipath.com/u/Palaniyappan)\
**Post date:** [October 1, 2019, 12:07pm UTC](https://forum.uipath.com/t/how-to-update-sql-table-by-passing-value-through-variable/155628/2 "2019-10-01T12:07:57Z")

</div>

> [@DivyaT](#):
>
> “Update midx\_table set Winesp\_Status=‘completed’ where ID=@cono”

use this same statement with value passed instead of variable @cono and execute that in your database server.  
lets check whether it is updating there when tried manually

Cheers @DivyaT

---

<div class="post-metadata">

**Author:** ![DivyaT](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/divyat/32/68625_2.png) [@DivyaT](https://forum.uipath.com/u/DivyaT)\
**Post date:** [October 1, 2019, 12:09pm UTC](https://forum.uipath.com/t/how-to-update-sql-table-by-passing-value-through-variable/155628/3 "2019-10-01T12:09:06Z")

</div>

Yeah I have checked its updtating

---

<div class="post-metadata">

**Author:** ![Palaniyappan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/palaniyappan/32/524095_2.png) [@Palaniyappan](https://forum.uipath.com/u/Palaniyappan)\
**Post date:** [October 1, 2019, 12:32pm UTC](https://forum.uipath.com/t/how-to-update-sql-table-by-passing-value-through-variable/155628/4 "2019-10-01T12:32:54Z")

</div>

Then it should work from uipath as well  
–use EXECUTE NON-QUERY activity and mention the sql statement

> **[Execute Non Query](https://docs.uipath.com/activities/docs/execute-non-query)**
>
> UiPath.Database.Activities.ExecuteNonQuery Executes an non query statement on a database. For UPDATE, INSERT, and DELETE statements, the return value is the number of rows affected by the command. For all other types of statements, the return value...

make sure the connection is made and we can check that with connection wizard where we got an option to check whether the connection is made ornot with TEST CONNECTIVITY option

kindly try this and let know for any queries or clarification  
Cheers @DivyaT

---

<div class="post-metadata">

**Author:** ![DivyaT](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/divyat/32/68625_2.png) [@DivyaT](https://forum.uipath.com/u/DivyaT)\
**Post date:** [October 1, 2019, 3:38pm UTC](https://forum.uipath.com/t/how-to-update-sql-table-by-passing-value-through-variable/155628/5 "2019-10-01T15:38:04Z")

</div>

Its not relevant to my question am trying to pass value through variable am unable to update anything in sql datatable

---

<div class="post-metadata">

**Author:** ![Palaniyappan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/palaniyappan/32/524095_2.png) [@Palaniyappan](https://forum.uipath.com/u/Palaniyappan)\
**Post date:** [October 1, 2019, 3:41pm UTC](https://forum.uipath.com/t/how-to-update-sql-table-by-passing-value-through-variable/155628/6 "2019-10-01T15:41:55Z")

</div>

hmm…

> [@DivyaT](#):
>
> unable to update anything in sql datatable

see if you were able to update that manually you must be able to do the same in UiPath as well  
–there must be only two reasons for this  
either there is no connectivity between UiPath and your database server  
or  
the query you have passed is not correct

–as you said the query is working perfectly fine, the only possiblility is with the connection  
thats what we need to check

hope now it relates to your question  
kindly let know for any queries or clarification

@DivyaT

---

<div class="post-metadata">

**Author:** ![DivyaT](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/divyat/32/68625_2.png) [@DivyaT](https://forum.uipath.com/u/DivyaT)\
**Post date:** [October 1, 2019, 4:36pm UTC](https://forum.uipath.com/t/how-to-update-sql-table-by-passing-value-through-variable/155628/7 "2019-10-01T16:36:00Z")

</div>

In sql script query is running but I dont know the syntax for writing in uipath because am not getting expected output and even any error on above syntax

---

<div class="post-metadata">

**Author:** ![DivyaT](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/divyat/32/68625_2.png) [@DivyaT](https://forum.uipath.com/u/DivyaT)\
**Post date:** [October 3, 2019, 4:06pm UTC](https://forum.uipath.com/t/how-to-update-sql-table-by-passing-value-through-variable/155628/8 "2019-10-03T16:06:03Z")

</div>

Please anyone update on my question.  
This is my query “UPDATE midx\_table  
SET WINESP\_STATUS= ‘Completed’  
WHERE ID=@c” am supplying value through argument but its not update anything in database

---

<div class="post-metadata">

**Author:** ![Neelam\_Jethani](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/neelam_jethani/32/188209_2.png) [@Neelam\_Jethani](https://forum.uipath.com/u/Neelam_Jethani)\
**Post date:** [November 26, 2020, 12:42pm UTC](https://forum.uipath.com/t/how-to-update-sql-table-by-passing-value-through-variable/155628/9 "2020-11-26T12:42:18Z")

</div>

Did you get the solution to your query im looking for the same thing can u help me out
