N8n connect with local SQL Server

I am still not able to connect to my local SQL Server from my local n8n. My is Windows authentication without username and password.. it cannot connect… .. but even when I created a username and password below, it failed too:

-- Run this in SSMS when connected with Windows auth
CREATE LOGIN n8n_user WITH PASSWORD = 'YourPassword123!', CHECK_POLICY = OFF;
USE SalesDemo;
CREATE USER n8n_user FOR LOGIN n8n_user;
ALTER ROLE db_owner ADD MEMBER n8n_user;  -- More permissions for testing

Hi there,

I see you are having trouble connecting to local sql server from your local installation, can you please download this workflow and see if it works,

```
{
  "name": "My workflow 2",
  "nodes": [
    {
      "parameters": {},
      "type": "n8n-nodes-base.manualTrigger",
      "typeVersion": 1,
      "position": [
        0,
        0
      ],
      "id": "be39e878-e39b-4b7c-9057-66deb490c35c",
      "name": "When clicking ‘Execute workflow’"
    },
    {
      "parameters": {
        "operation": "executeQuery",
        "query": "create * from pets;"
      },
      "type": "n8n-nodes-base.microsoftSql",
      "typeVersion": 1.1,
      "position": [
        208,
        0
      ],
      "id": "46f6eb7d-0832-4960-a5b3-d7ff912737c6",
      "name": "Microsoft SQL",
      "credentials": {
        "microsoftSql": {
          "id": "eLYkSIo0XpJgvFdD",
          "name": "Microsoft SQL account 2"
        }
      }
    }
  ],
  "pinData": {},
  "connections": {
    "When clicking ‘Execute workflow’": {
      "main": [
        [
          {
            "node": "Microsoft SQL",
            "type": "main",
            "index": 0
          }
        ]
      ]
    }
  },
  "active": false,
  "settings": {
    "executionOrder": "v1"
  },
  "versionId": "30a5493a-ff28-42a6-b54e-327a39fbf0b8",
  "meta": {
    "templateCredsSetupCompleted": true,
    "instanceId": "316dcdd65a8a62f8bdab1bf9efb9f5f42c8c0503bbd989b8df5cce35c599fe45"
  },
  "id": "ZfGz4BL2KJzHOZ3K",
  "tags": []
}

```

Also please ensure to add the correct database, port, username and password in the below dialog and try again,

Cheers!

1 Like

@TH1

If you’re running n8n docker image and also use SQL server in docker make sure both are in same network.

that was extactly what I am doing, but I could not get the connection through.

could there be any firewall issue, as I read from MSSQL connection problem with instance - #17 by christiaanwesterbeek but I am actually testing everything in local PC (not even using Docker), so there should not be any firewall issue.

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