# How to pass variables to the MSSQL-Node?

**URL:** https://discourse.nodered.org/t/how-to-pass-variables-to-the-mssql-node/19495
**Category:** General
**Created:** [23 December 2019 09:23 UTC](https://discourse.nodered.org/t/how-to-pass-variables-to-the-mssql-node/19495 "2019-12-23T09:23:33Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Golonder](https://avatars.discourse-cdn.com/v4/letter/g/eada6e/32.png) [@Golonder](https://discourse.nodered.org/u/Golonder)
#### Post date: [23 December 2019 09:23 UTC](https://discourse.nodered.org/t/how-to-pass-variables-to-the-mssql-node/19495/1 "2019-12-23T09:23:33Z")

</div>

Hi,  
I would like to insert several values into my MSSQL-Database using the MSSQL-Node.  
Unfortunately it does not seem to work the way it is described.

I prepare an object with two variables:

```auto
var a = {};
a.SQL_Parameter = "Baroso";
a.SQL_Value = "1";
return a;

```

In the MSSQL-Node I try to use these two values in an INSERT-Statement:

```auto
insert into webtest
select getdate(),'test','{{{msg.SQL_Parameter}}}','{{{msg.SQL_Value}}}','','','','',''

```

All I get is one line with empty fields in the database-table.

```auto
[{"id":"66444e8c.457ed","type":"function","z":"607d461d.a97708","name":"True / False","func":"var a = {};\n\na.SQL_Parameter = \"Baroso\";\na.SQL_Value = \"1\";\n \nreturn a;\n\n","outputs":1,"noerr":0,"x":450,"y":440,"wires":[["90f55686.238258","bfa799ab.b1cb48"]]},{"id":"90f55686.238258","type":"MSSQL","z":"607d461d.a97708","mssqlCN":"576100aa.9e891","name":"","query":"--INSERT INTO Weblog (id, name, quantity) VALUES ({{{payload.id}}}, \n--'{{{global.name}}}', 1)\n\ndeclare @hose varchar;\nset @hose = '{{{msg.SQL_Parameter}}}';\n\ninsert into webtest\nselect getdate(),'test',@hose,@hose,'','','','',''\n","outField":"payload","returnType":0,"throwErrors":1,"x":760,"y":420,"wires":[[]]},{"id":"bfa799ab.b1cb48","type":"debug","z":"607d461d.a97708","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"true","targetType":"full","x":750,"y":360,"wires":[]},{"id":"d3992c9c.e9627","type":"inject","z":"607d461d.a97708","name":"","topic":"","payload":"","payloadType":"date","repeat":"","crontab":"","once":false,"onceDelay":0.1,"x":220,"y":440,"wires":[["66444e8c.457ed"]]},{"id":"576100aa.9e891","type":"MSSQL-CN","z":"","tdsVersion":"7_4","name":"","server":"10.0.0.19","port":"1433","encyption":true,"database":"WeblogDB","useUTC":true,"connectTimeout":"15000","requestTimeout":"15000","cancelTimeout":"5000","pool":"5"}]

```

Am I doing it wrong ?

BR  
Gawan

---

<div class="post-metadata">

### Author: ![Golonder](https://avatars.discourse-cdn.com/v4/letter/g/eada6e/32.png) [@Golonder](https://discourse.nodered.org/u/Golonder)
#### Post date: [23 December 2019 23:53 UTC](https://discourse.nodered.org/t/how-to-pass-variables-to-the-mssql-node/19495/2 "2019-12-23T23:53:22Z")

</div>

any idea ?

---

<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: [23 April 2020 13:56 UTC](https://discourse.nodered.org/t/how-to-pass-variables-to-the-mssql-node/19495/3 "2020-04-23T13:56:25Z")

</div>

@Golonder and anyone in the future.

you leave the `msg` part off

e.g. `select getdate(),'test','{{{SQL_Parameter}}}','{{{SQL_Value}}}','','','','',''`

I have just published an update to [node-red-contrib-mssql-plus](https://flows.nodered.org/node/node-red-contrib-mssql-plus) and clarifed this in the built in node help...

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

sorry for the delayed reply (I'm certain you got past this long ago)

---

<div class="post-metadata">

### Author: ![Nodi.Rubrum](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/nodi.rubrum/32/107482_2.png) [@Nodi.Rubrum](https://discourse.nodered.org/u/Nodi.Rubrum)
#### Post date: [8 August 2020 02:11 UTC](https://discourse.nodered.org/t/how-to-pass-variables-to-the-mssql-node/19495/4 "2020-08-08T02:11:47Z")

</div>

Nice update to documentation however. I tripped over this issue in the past, had me guessing until some gave me insight.
