# How to Check whether the SQL Query was Successful or Failed?

**URL:** <https://discourse.nodered.org/t/how-to-check-whether-the-sql-query-was-successful-or-failed/7950>\
**Category:** Dashboard\
**Created:** [14 February 2019 02:19 UTC](https://discourse.nodered.org/t/how-to-check-whether-the-sql-query-was-successful-or-failed/7950 "2019-02-14T02:19:31Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![rishanaziz](https://avatars.discourse-cdn.com/v4/letter/r/f14d63/32.png) [@rishanaziz](https://discourse.nodered.org/u/rishanaziz)\
**Post date:** [14 February 2019 02:19 UTC](https://discourse.nodered.org/t/how-to-check-whether-the-sql-query-was-successful-or-failed/7950/1 "2019-02-14T02:19:31Z")

</div>

Hi all,

I need to do a checking whether the SQL query was successful or failed in an **if else** statement for both MySQL (msg.topic) and MSSQL (msg.payload).

For example:

```auto
msg.topic = "UPDATE test SET name='Login' WHERE id='123'";

if ( /* Condition to indicate that the query is successful */ ) {
   msg.payload = "Query was successful"; 
}
else {
   msg.payload = "Query failed";
}

```

Tagging @knolleary and @thiren for this topic discussion.

---

<div class="post-metadata">

**Author:** ![ukmoose](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/ukmoose/32/13_2.png) [@ukmoose](https://discourse.nodered.org/u/ukmoose)\
**Post date:** [14 February 2019 07:41 UTC](https://discourse.nodered.org/t/how-to-check-whether-the-sql-query-was-successful-or-failed/7950/2 "2019-02-14T07:41:51Z")

</div>

Mmmm. Why do you only want those people to answer?

You set the msg.topic node up in a function node PRIOR to the SQL node where the SQL QUERY is performed so an IF statement where you have it is before the query takes place.

So is that all you have tried? Have you looked at placing a debug AFTER the SQL node? Have you looked at the CATCH or STATUS nodes?
