# Using mustache variables in MSSQL node

**URL:** https://discourse.nodered.org/t/using-mustache-variables-in-mssql-node/24002
**Category:** General
**Created:** [31 March 2020 22:17 UTC](https://discourse.nodered.org/t/using-mustache-variables-in-mssql-node/24002 "2020-03-31T22:17:12Z")
**Posts on this page:** 3
**Page:** 1

<div class="post-metadata">

### Author: ![coasterguru](https://avatars.discourse-cdn.com/v4/letter/c/9e8a1a/32.png) [@coasterguru](https://discourse.nodered.org/u/coasterguru)
#### Post date: [31 March 2020 22:17 UTC](https://discourse.nodered.org/t/using-mustache-variables-in-mssql-node/24002/1 "2020-03-31T22:17:13Z")

</div>

SQL node says I can use moustache format, but I can't figure out why I can't set a SQL variable from a msg. variable. See my example flow:  
`[{"id":"c38ee7de.9bcf38","type":"MSSQL","z":"a02264a3.bc4628","mssqlCN":"29537ce.b674c84","name":"SQL Query","query":"--Use External Variable for Query--\nDECLARE @group nvarchar(30);\nSET @group = {{{msg.team}}} ;\n\n SELECT groupName AS Result\n FROM TestTable\n WHERE groupName LIKE @group\n","outField":"payload","x":550,"y":900,"wires":[["1cced548.cc9ccb","bc3a7a2f.31dee8"]]},{"id":"1cced548.cc9ccb","type":"function","z":"a02264a3.bc4628","name":"Read Query","func":"msg.result = {};\n\nmsg.result['Team'] = msg.payload[0].Result;\n\nreturn msg;","outputs":1,"noerr":0,"x":770,"y":900,"wires":[["1bb34f54.da0021"]]},{"id":"c2d57dfb.6771d","type":"function","z":"a02264a3.bc4628","name":"Set SQL Variable","func":"\nmsg.team = 'Team';\nreturn msg;","outputs":1,"noerr":0,"x":330,"y":900,"wires":[["c38ee7de.9bcf38","61ecd924.999e18"]]},{"id":"61ecd924.999e18","type":"debug","z":"a02264a3.bc4628","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":430,"y":820,"wires":[]},{"id":"1bb34f54.da0021","type":"debug","z":"a02264a3.bc4628","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":870,"y":820,"wires":[]},{"id":"5a467a04.370bf4","type":"inject","z":"a02264a3.bc4628","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":140,"y":900,"wires":[["c2d57dfb.6771d"]]},{"id":"bc3a7a2f.31dee8","type":"debug","z":"a02264a3.bc4628","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":650,"y":820,"wires":[]},{"id":"29537ce.b674c84","type":"MSSQL-CN","z":"","name":"blah","server":"blah","encyption":true,"database":""}]`

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [31 March 2020 23:14 UTC](https://discourse.nodered.org/t/using-mustache-variables-in-mssql-node/24002/2 "2020-03-31T23:14:12Z")

</div>

use `{{{team}}}` not `{{{msg.team}}}`

NOTE: I am using the node-red-contrib-mssql-plus. there are a number of bug fixes and improvements over the original. YMMV

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

---

<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: [30 May 2020 23:14 UTC](https://discourse.nodered.org/t/using-mustache-variables-in-mssql-node/24002/3 "2020-05-30T23:14:17Z")

</div>

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