SQL results different between n8n and SQL studio

Hi!

I’m trying to build a workflow to sync datas from a SQL database to a MySQL database. We actually are using dbsync with XMLs files, it works but we would like to change to n8n.

I’m running a first query which give me about 18000 results on SQL Management Studio. When I’m using n8n with the same query, it returns : 1 item [ ]

What could be the reason ?

Thanks a lot for your help !

  • n8n version:1.21.1
  • Running n8n via (Docker, npm, n8n cloud, desktop app):npm
  • Operating system:debian

It looks like your topic is missing some important information. Could you provide the following if applicable.

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

Trying to share the workflow but I get a 403 error :face_with_diagonal_mouth:

So the sql node returns 1 item with all data, or it is empty?

About 403 error: If you have html or xml node, remove it as it may be the reason.

In the output I have

1 item
[
]

In JSON and

1 item
No data to show - item(s) exist, but they’re empty

in Schema. As far as HTML or XML in my query, I’m not sure, to me it’s pure SQL

Put the SQL code in a pastebin

Thanks for your help!

        SELECT
          CST.[No_],
          [Name],
          CASE 
            WHEN cst.[profil] = 0 AND cst.[Client Prime] = 0 AND cst.[Gen_ Bus_ Posting Group] <> 'DOMTOM' AND cst.safety = 0 THEN 3
            WHEN cst.[profil] = 0 AND cst.[Client Prime] = 1 AND cst.[Gen_ Bus_ Posting Group] <> 'DOMTOM' AND cst.safety = 0 THEN 18
            WHEN cst.[profil] = 1 THEN 4
            WHEN cst.[profil] = 2 AND cst.safety = 0 THEN 5
            WHEN CST.[Profil] = 3 AND cst.safety = 0 AND (cst.[Criteria 1] = 'DISTRIBUTEUR' OR CST.[Profil] = 3 AND cst.[Criteria 1] = 'CHAINE') THEN 8
            WHEN CST.[Profil] = 3 AND cst.safety = 0 AND cst.[Criteria 1] = 'OPTICIEN' AND cst.[Client Prime] = 0 THEN 3
            WHEN CST.[Profil] = 3 AND cst.[Criteria 1] = 'OPTICIEN' AND cst.[Client Prime] = 1 AND cst.safety = 0 THEN 18
            WHEN CST.[Profil] = 3 AND cst.[Criteria 1] = 'AGENT' AND cst.[Client Prime] = 0 AND cst.safety = 0 THEN 3
            WHEN CST.[Profil] = 3 AND cst.[Criteria 1] = 'AGENT' AND cst.[Client Prime] = 1 AND cst.safety = 0 THEN 18
            WHEN cst.[profil] = 4 AND cst.[Client Prime] = 0 AND cst.[Gen_ Bus_ Posting Group] <> 'DOMTOM' AND cst.safety = 0 THEN 6
            WHEN cst.[profil] = 5 THEN 7
            WHEN cst.[profil] = 4 AND cst.[Client Prime] = 1 AND cst.[Gen_ Bus_ Posting Group] <> 'DOMTOM' AND cst.safety = 0 THEN 16 
            WHEN cst.[profil] = 16 AND cst.[Client Prime] = 1 AND cst.safety = 0 THEN 18
            WHEN cst.[profil] = 17 AND cst.safety = 0 THEN 17 
            WHEN cst.[profil] = 4 AND cst.[Gen_ Bus_ Posting Group] = 'DOMTOM' AND cst.safety = 0 THEN 17
            WHEN cst.[profil] = 0 AND cst.[Gen_ Bus_ Posting Group] = 'DOMTOM' AND cst.safety = 0 THEN 5
            WHEN cst.[profil] = 6 AND cst.safety = 0 THEN 9 
            WHEN cst.[profil] = 7 AND cst.safety = 0 THEN 10
            WHEN cst.[profil] = 0 AND cst.safety = 1 THEN 19
            WHEN CST.[Profil] = 8 THEN 20 
            WHEN CST.[Profil] = 9 THEN 21 
          END AS [Profil],
          CST.[Bill-to Customer No_],
          CASE WHEN CST.[Language Code] IN ('', 'FRA', 'ES') THEN 1 ELSE 6 END AS [id_lang],
          CST.[Trade Register],
          CST.[APE Code],
          RTRIM(LTRIM(CST.[E-mail])) AS [E-mail],
          '' AS [Home Page],
          CST.[Password],
          CST.[Customer Price Group],
          CST.[Criteria 6],
          CAST(COALESCE(CPG.zone, 0) AS INT) AS discount_fieldno,
          CST.[own_customer],
          CASE WHEN CST.[Currency Code] = 'USD' THEN CST.[Currency Code] ELSE '' END AS currency_code
        INTO [##Customern8n]
        FROM [dbo].[Opal$Customer] CST
        LEFT OUTER JOIN [Opal$Customer Price Group] CPG ON CST.[Customer Price Group] = CPG.Code
        WHERE [E-mail] <> '' AND [Password] <> '' AND [Published] = 1
          AND [E-Mail] LIKE '%@%'

Weird enough, I do have the same issue with this query on N8N, and when I paste it here I do have a 403 error as well. But, if I paste a bunch of lines, then some more, and then what’s left, I don’t have a 403 :face_with_monocle:

Hi!

Could it be the temporary SQL table ? Does n8n handle them?

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