# Node-red returns empty when sending query to Microsoft SQL Server

**URL:** <https://discourse.nodered.org/t/node-red-returns-empty-when-sending-query-to-microsoft-sql-server/74555>\
**Category:** General\
**Tags:** database\
**Created:** [1 February 2023 12:53 UTC](https://discourse.nodered.org/t/node-red-returns-empty-when-sending-query-to-microsoft-sql-server/74555 "2023-02-01T12:53:20Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Davih\_andrade](https://avatars.discourse-cdn.com/v4/letter/d/2acd7d/32.png) [@Davih\_andrade](https://discourse.nodered.org/u/Davih_andrade)\
**Post date:** [1 February 2023 12:53 UTC](https://discourse.nodered.org/t/node-red-returns-empty-when-sending-query-to-microsoft-sql-server/74555/1 "2023-02-01T12:53:20Z")

</div>

Hi, i’m having a problem using Microsoft SQL server with node-red and i hope someone can help me, also sorry if i'm not using the correct format for the post. I’m using the mssql-plus pallete and it Works in general, i send a string with the query and i’m returned with the result, but when i try some commands it just returns empty. I have already tried the same queries directly in SQL server and it Works just fine, but not when i do it through node-red. I was initialy suspecting that the return was too long or maybe the request time was too long, but nothing changed after increasing these in the mssql-plus settings, and later i proved that it was not the case, since i did a query with a very big return and it worked, but when i try a small query with some specific commands it just don’t work.

Example that don’t work:

 ![1](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/3/738604b7f570eb8c3ef94b2b1aa467ff1fab8a08.png)

Example that work:

 ![3](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/c/6c0b91eeb2d53116ab293824827e9cb17564d772.png)

The two examples are the same query, just changing somethings, the first example don’t work, but when i do the same query with minus one “where”, it Works, and when i do the same query with no “where” at all it also Works (i could not send the third image because new users can only send two images). The query with no “where” takes a larger amount of time and have a larger return than the one that don’t work, so it is not a time out or a limit in the return size. Also i can't send the node-red JSON because it only works with the database and i'm not autorized to share the database, i hope you guys can help me with the limited information i'm providing. If something is not clear just ask and i will gladly do my best to explain. Thanks in advance.

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [1 February 2023 13:08 UTC](https://discourse.nodered.org/t/node-red-returns-empty-when-sending-query-to-microsoft-sql-server/74555/2 "2023-02-01T13:08:26Z")

</div>

Hi @Davih_andrade - Welcome to forums

The only difference I see is the `year` clause.  
Therefore, are you sure you have records that have dates that

- Has the Day of **10**
- Has the Month of **7**
- Has the Year of **2022**

If omitting the `year` clause yields records, then it would seem to me that there are no records of that date in **2022** that match the criteria 🤷‍♂️

---

<div class="post-metadata">

**Author:** ![Davih\_andrade](https://avatars.discourse-cdn.com/v4/letter/d/2acd7d/32.png) [@Davih\_andrade](https://discourse.nodered.org/u/Davih_andrade)\
**Post date:** [1 February 2023 13:12 UTC](https://discourse.nodered.org/t/node-red-returns-empty-when-sending-query-to-microsoft-sql-server/74555/3 "2023-02-01T13:12:48Z")

</div>

Hi, thanks for the response! I don't think it was 100% clear in my post, but the query returns just fine when i run the code directly in the SQL server, and just when i do it through node-red it returns empty.

---

<div class="post-metadata">

**Author:** ![marcus-j-davies](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/marcus-j-davies/32/103435_2.png) [@marcus-j-davies](https://discourse.nodered.org/u/marcus-j-davies)\
**Post date:** [1 February 2023 13:17 UTC](https://discourse.nodered.org/t/node-red-returns-empty-when-sending-query-to-microsoft-sql-server/74555/4 "2023-02-01T13:17:01Z")

</div>

Ah right ok...

the second query that works - are the 2 datasets identical? Node RED vs SSMS  
I wonder if it's an international format thing with the date?

can you try `YYYY-MM-DD`?

---

<div class="post-metadata">

**Author:** ![Davih\_andrade](https://avatars.discourse-cdn.com/v4/letter/d/2acd7d/32.png) [@Davih\_andrade](https://discourse.nodered.org/u/Davih_andrade)\
**Post date:** [1 February 2023 13:21 UTC](https://discourse.nodered.org/t/node-red-returns-empty-when-sending-query-to-microsoft-sql-server/74555/5 "2023-02-01T13:21:43Z")

</div>

That was exactly the problem, thank you very much!

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [15 February 2023 13:22 UTC](https://discourse.nodered.org/t/node-red-returns-empty-when-sending-query-to-microsoft-sql-server/74555/6 "2023-02-15T13:22:29Z")

</div>

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