Inserting Null Values into SQL Server

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!

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

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


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

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])
{{ $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’ }}

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):


Thank you! That worked perfectly.


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