Returnvalue of MSSQL Query Select Count

Hello, I'm using the node-red-contrib-mssql-plus
Everthing works well!
One thing is strange and Im struggeling ;(
The Returnvalue of the command Select Count returns the right Value but I can't use the returnvalue. The debugmessage shows the following:
9.12.2021, 14:48:52node: 8c733af0095bc140
site1 : msg.payload : array[1]
array[1]
0: object
499999
I cant view this Value 499999 in the dashboard. There allways appear: [{"":499999}]

Where is my mistake?
Thnaks in Advance

You need to tell the dashboard node that the value is in msg.payload[0], so in the Value Format field put {{msg.payload[0]}}

If have try'd this also with the same Result!
If I use your suggestion in the debug window it shows:
9.12.2021, 15:36:37node: 8c733af0095bc140
site1 : msg.msg.payload[0] : Object
object
499999

Ah, I see the 499999 is an object somehow. Feed it through a JSON node and then to a debug node and show us what it says.

Actually, that tells us the answer. The element is an object with an empty key name (or unprintable character). In a function node you can use something like

msg.payload = Object.entries(msg.payload[0])[0][1]
return msg;

which returns the value of the first key in the object in the first element of msg.payload.
Why the node gives you such a bizarre return is beyond me.

The results of a query to MSSQL is array of objects where the property names are the field names.

Try changing your query to something like select count(*) as RowCount from myTable

Also, instead of selecting text in the debug panel, please use the copy value button that appears under your mouse cursor when you hover over the payload in the debug window. And please use the code button when pasting code/data into the forum.


Canned replies...


Canned reply 1...

in order to make code more readable and importable it is important to surround your code with three backticks
```
like this
```

See this post for more details - How to share code or flow json

Canned reply 2...

There’s a great page in the docs that will explain how to use the debug panel to find the right path to any data item.

Pay particular attention to the part about the buttons that appear under your mouse pointer when you over hover a debug message property in the sidebar.

BX00Cy7yHi

https://nodered.org/docs/user-guide/messages

Thanks, the hint with
''' as RowCount''' was very helpfull, now the object Name is defined and i can read out the value of RowCount
Thank you verry much!!!

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