Let the agent store a self made schema in Microsoft SQL

Hey.
I have this problem where I want the AI agent to create a trainingschema for me, and then store it to Microsoft SQL. But I can’t get the agent to save it correctly in the SQL file.
The insert Microsoft SQL node gives the following error in the picture. When I let the AI agent make a schema and save it, it will say it did so succesfully, but the file ends up empty.

Describe the problem/error/question

What is the error message (if any)?

Please share your workflow

(Select the nodes on your canvas and use the keyboard shortcuts CMD+C/CTRL+C and CMD+V/CTRL+V to copy and paste the workflow.)

Share the output returned by the last node

Information on your n8n setup

  • n8n version:
  • Database (default: SQLite):
  • n8n EXECUTIONS_PROCESS setting (default: own, main):
  • Running n8n via (Docker, npm, n8n cloud, desktop app):
  • Operating system:

It appears the data which was attempted to be written to the table had null (or didn’t have a value) for the column datum, which is not allowed to be empty by the table schema.

Is there a way for an empty table to exist and it being filled by the AI as it goes?

Absolutely, this is totally fine, just make sure that when AI does call all the values marked as NOT NULL in the schema are provided. Otherwise the DB will reject that insert you will get an error like you showed.

How do I do that with an empty table?

How do you do what with an empty table?

Well I want the AI to be able to insert rows like this into the Microsoft SQL file. But the SQL database starts off as an empty table with just column names. I’m not sure what you meant with NOT NULL values in the schema


When I do let the AI generate a schema and try to make him save it into an SQL database, It seems like the AI wants to put all the activities of a day into one cell.

you previously shared a screenshot where the error was Cannot insert value NULL into column 'datum'. This error means that the attempted insert had no value for the column that doesn’t accept that in its schema definition. Meaning that when the table was created it was created with a “contract” that all rows will necessarily have a value for this column. The insert attempted in the screenshot above (initial message) violated that “contract”.

If it wants to pull all activities in a single cell, that means your prompt is not well structured and doesn’t instruct the agent how to use the tool properly.

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