# Inserting Null Values into SQL Server

**URL:** <https://community.n8n.io/t/inserting-null-values-into-sql-server/31358>\
**Category:** Questions\
**Tags:** microsoft-sql\
**Created:** [October 9, 2023, 1:24pm UTC](https://community.n8n.io/t/inserting-null-values-into-sql-server/31358 "2023-10-09T13:24:34Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![JWeitzel](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@JWeitzel](https://community.n8n.io/u/JWeitzel)\
**Post date:** [October 9, 2023, 1:24pm UTC](https://community.n8n.io/t/inserting-null-values-into-sql-server/31358/1 "2023-10-09T13:24:34Z")

</div>

Hi all,  
I’m trying to insert and update rows in a SQL Server database with NULL values. The issue that I’m having is that I continuously receive an error message with no additional information. I have ensured that the table allows for NULL values in those columns and I have tried using the syntax recommended in another forum post about inserting NULLs. Any help on this issue would be appreciated!

 ![NULL Value Error](https://europe1.discourse-cdn.com/n8n/original/3X/8/e/8e8e19b0949c541031d4f77c708d8c09e9795ffa.png)

---

<div class="post-metadata">

**Author:** ![barn4k](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/barn4k/32/8170_2.png) [@barn4k](https://community.n8n.io/u/barn4k)\
**Post date:** [October 9, 2023, 3:05pm UTC](https://community.n8n.io/t/inserting-null-values-into-sql-server/31358/3 "2023-10-09T15:05:15Z")

</div>

hi @JWeitzel  
I do not have SQL, so I assume to try one of:

`{{ $json.LaserficheUsername || null}}, {{ $json.ManagerNumber || null }}, {{ $json.Status }}`

or

`{{ $json.LaserficheUsername }}, {{ $json.ManagerNumber }}, {{ $json.Status }}`

---

<div class="post-metadata">

**Author:** ![JWeitzel](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@JWeitzel](https://community.n8n.io/u/JWeitzel)\
**Post date:** [October 10, 2023, 7:17pm UTC](https://community.n8n.io/t/inserting-null-values-into-sql-server/31358/4 "2023-10-10T19:17:33Z")

</div>

Thanks for the response!

After trying both of those options, I’m still getting a blank error. In each of those cases, the data preview shows as “, , Active” so it appears as if the node isn’t reading a value when it should be reading NULL.

Here is a full sample of SQL that I have tried that also resulted in the blank Error message:

INSERT INTO employee ([EmployeeID], [LaserficheUsername], [ManagerNumber], [Status])  
VALUES (  
{{ $json[“employeeNumber”] ? $json[“employeeNumber”] : ‘NULL’ }},  
{{ $json[“value”] ? “'” + $json[“value”] + “'” : ‘NULL’ }},  
{{ $json.positionData.manager ? $json.positionData.manager.employeeNumber : ‘NULL’ }},  
{{ $json.statusData[“status”] ? “'” + $json.statusData[“status”] + “'” : ‘NULL’ }}  
);

---

<div class="post-metadata">

**Author:** ![MutedJam](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/mutedjam/32/70851_2.png) [@MutedJam](https://community.n8n.io/u/MutedJam)\
**Post date:** [October 11, 2023, 11:00am UTC](https://community.n8n.io/t/inserting-null-values-into-sql-server/31358/6 "2023-10-11T11:00:37Z")

</div>

Hi @JWeitzel, I am sorry you are having trouble.

The Microsoft SQL node would work slightly different from what you might expect. The columns field on your screenshot expects the names of the incoming fields, not their values for the update to work.

So assuming your fields in n8n match the fields in your database table, something like this should work (just `LaserficheUsername, ManagerNumber, Status` without any expressions):

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/6/7/670eb75d5da8ac1f4864cb900940570d9167bc0b.png)

---

<div class="post-metadata">

**Author:** ![JWeitzel](https://avatars.discourse-cdn.com/v4/letter/j/e99b99/32.png) [@JWeitzel](https://community.n8n.io/u/JWeitzel)\
**Post date:** [October 13, 2023, 8:23pm UTC](https://community.n8n.io/t/inserting-null-values-into-sql-server/31358/7 "2023-10-13T20:23:26Z")

</div>

Thank you! That worked perfectly.

---

<div class="post-metadata">

**Author:** ![system](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/system/32/195824_2.png) [@system](https://community.n8n.io/u/system)\
**Post date:** [October 20, 2023, 8:23pm UTC](https://community.n8n.io/t/inserting-null-values-into-sql-server/31358/8 "2023-10-20T20:23:27Z")

</div>

Closed on October 20, 2023, 8:23pm UTC

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