# SQL Database Query

**URL:** <https://forum.uipath.com/t/sql-database-query/446923>\
**Category:** Robot\
**Tags:** question, robot, database, activities\
**Created:** [June 9, 2022, 12:21pm UTC](https://forum.uipath.com/t/sql-database-query/446923 "2022-06-09T12:21:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ishan\_Shelke1](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/ishan_shelke1/32/271680_2.png) [@Ishan\_Shelke1](https://forum.uipath.com/u/Ishan_Shelke1)\
**Post date:** [June 9, 2022, 12:21pm UTC](https://forum.uipath.com/t/sql-database-query/446923/1 "2022-06-09T12:21:14Z")

</div>

Is there any activity available in UiPath by which I compare two tables of a SQL database ?

---

<div class="post-metadata">

**Author:** ![Mr.StarLord\_AO](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/mr.starlord_ao/32/106797_2.png) [@Mr.StarLord\_AO](https://forum.uipath.com/u/Mr.StarLord_AO)\
**Post date:** [June 9, 2022, 5:34pm UTC](https://forum.uipath.com/t/sql-database-query/446923/2 "2022-06-09T17:34:57Z")

</div>

you could use execute query activity and there you can you some compare logic as mentioned in below link

> **[Quick and best way to Compare Two Tables in SQL - DWgeek.com](https://dwgeek.com/quick-best-way-compare-two-tables-sql.html/)**
>
> Say you have requirement to compare two tables. You have two tables in same database or server that you wish to compare, and check if any changes in the column values or see if any row is missing in either of tables. Below are some of the methods you...

> **[Execute Query](https://docs.uipath.com/activities/docs/execute-query)**
>
> UiPath.Database.Activities.ExecuteQuery Executes a query on a database and returns the query result in a Datatable. Properties Common ContinueOnError - Specifies if the automation should continue even when the activity throws an error. This field...

---

<div class="post-metadata">

**Author:** ![Rahul\_Unnikrishnan](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/rahul_unnikrishnan/32/464046_2.png) [@Rahul\_Unnikrishnan](https://forum.uipath.com/u/Rahul_Unnikrishnan)\
**Post date:** [June 9, 2022, 5:54pm UTC](https://forum.uipath.com/t/sql-database-query/446923/3 "2022-06-09T17:54:28Z")

</div>

Hello @Ishan_Shelke1

The best way is to use Execute Query in both the tables and you will get 2 datatables. You can easily compare those data. There are no readymade activities for doing it directly in the database.

---

<div class="post-metadata">

**Author:** ![system](https://sea2.discourse-cdn.com/uipath/user_avatar/forum.uipath.com/system/32/182466_2.png) [@system](https://forum.uipath.com/u/system)\
**Post date:** [June 12, 2022, 5:54pm UTC](https://forum.uipath.com/t/sql-database-query/446923/4 "2022-06-12T17:54:44Z")

</div>

Closed on June 12, 2022, 5:54pm UTC

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