# MySQL to SQL Server

**URL:** <https://community.n8n.io/t/mysql-to-sql-server/33056>\
**Category:** Questions\
**Tags:** microsoft-sql, mysql\
**Created:** [November 17, 2023, 9:57am UTC](https://community.n8n.io/t/mysql-to-sql-server/33056 "2023-11-17T09:57:18Z")\
**Posts on this page:** 20\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://community.n8n.io/u/Jonathan)\
**Post date:** [November 17, 2023, 9:57am UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/1 "2023-11-17T09:57:18Z")

</div>

Hi !

Sorry for the dumb question, but I’m trying to synch values from a MySQL to a SQL Server. I’m connected to both db and I do run a Query on the MySQL to return the results I want

SELECT \*  
FROM prestashop\_orders  
WHERE extracted = 2;

Now I’d like insert some fields from the table to the SQL server, for exemple the value from the field “reference” from the MySQL table “prestashop\_orders” to “Your Reference” field from the table Test$TempSalesHeader in the SQL Server.

Thanks for your help !

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [November 17, 2023, 10:56am UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/3 "2023-11-17T10:56:14Z")

</div>

Hey @Jonathan,

Welcome to the community 🍰

Have you tried adding an Edit Fields node between the MySQL node and the SQL node to change the field names then using the insert option in the SQL node?

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://community.n8n.io/u/Jonathan)\
**Post date:** [November 17, 2023, 11:27am UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/4 "2023-11-17T11:27:43Z")

</div>

Hi ! Thanks for the prompt reply and idea !

Just tried, so far it looks like this but not sure I’m doing what I should, still get an error ☹

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [November 17, 2023, 11:46am UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/5 "2023-11-17T11:46:29Z")

</div>

Hey @Jonathan,

What error are you seeing?

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://community.n8n.io/u/Jonathan)\
**Post date:** [November 17, 2023, 12:58pm UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/6 "2023-11-17T12:58:00Z")

</div>

Unfortunately, error message is not very detailed !

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/3/3/33cb58dc8541b87b82b86aae6a6fda65fb8fdbd3.png)

Edit: on the screenshot it shows [‘Your Reference’],[‘Your Reference’] in columns, it was a test, I get the same error with only one [‘Your Reference’]

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [November 17, 2023, 1:14pm UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/7 "2023-11-17T13:14:57Z")

</div>

Well that is super helpful, I will have to fix that error 🙂

What is the name of the column in the database is it just `Your Reference`?

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://community.n8n.io/u/Jonathan)\
**Post date:** [November 17, 2023, 2:08pm UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/8 "2023-11-17T14:08:37Z")

</div>

😂

This is the column in the MySQL db

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/1/7/1721a648cec8f97dd19b376f7076ad063b37f044.png)

This is the column in the MSSQL db

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/0/6/0642de64bec0d6a36fb0ce21d025409bd013e3fe.png)

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [November 17, 2023, 3:59pm UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/9 "2023-11-17T15:59:01Z")

</div>

I wonder if the space is causing the issue, Rather than [‘Your Reference’] what happens if you just try `Your Reference` or `'Your Reference'`?

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://community.n8n.io/u/Jonathan)\
**Post date:** [November 20, 2023, 8:32am UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/10 "2023-11-20T08:32:53Z")

</div>

Hi!

When I try just ‘Your Reference’ I get  
_ERROR: Invalid column name ‘‘Your Reference’’._

It’s a bit better when I put Your Reference  
_ERROR: Cannot insert the value NULL into column ‘Interface Type’, table ‘NavOpal.dbo.Opal$TempSalesHeader’; column does not allow nulls. INSERT fails._

For information

![image](https://europe1.discourse-cdn.com/n8n/original/3X/e/b/eb7c0561b260e476859b8e34481dd5327cc89312.png)

I don’t know why it’s trying to insert into column Interface Type, it’s the first with a space in its name, if it’s of any help!

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [November 20, 2023, 11:21am UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/11 "2023-11-20T11:21:13Z")

</div>

Hey @Jonathan,

What happens if you add the `Interface Type` to your query? It sounds like the Table requires an option for that which isn’t in the data you are sending.

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://community.n8n.io/u/Jonathan)\
**Post date:** [November 20, 2023, 4:43pm UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/12 "2023-11-20T16:43:37Z")

</div>

Maybe I should try another way to do it

If I try this query

UPDATE Opal$TempSalesHeader  
SET [Your Reference] = ‘123456’  
WHERE [Source Document No\_] = ‘989962’;

It does work.

Now, how can I synch for exemple “reference” to “Your Reference” ? How do I map them ?

 ![image](https://europe1.discourse-cdn.com/n8n/original/3X/4/b/4bb0b508feeb277b9f052ef789f70a071d822713.png)

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [November 20, 2023, 4:46pm UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/13 "2023-11-20T16:46:02Z")

</div>

That would do it, So in that case in your query you would need to change the numbers to use an expression based on the previous data.

```auto
UPDATE Opal$TempSalesHeader
SET [Your Reference] = {{ $json.reference }}
WHERE [Source Document No_] = ‘989962’;

```

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://community.n8n.io/u/Jonathan)\
**Post date:** [November 20, 2023, 4:49pm UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/14 "2023-11-20T16:49:30Z")

</div>

> [@Jon](#):
>
> ```auto
> UPDATE Opal$TempSalesHeader
> SET [Your Reference] = {{ $json.reference }}
> WHERE [Source Document No_] = ‘989962’;
> 
> ```

With your code I get ERROR: Incorrect syntax near ‘‘’.

If I replace `’` by `'` I get ERROR: Invalid column name ‘undefined’. 🧐

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [November 20, 2023, 4:53pm UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/15 "2023-11-20T16:53:31Z")

</div>

Did you change the field to use an expression?

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://community.n8n.io/u/Jonathan)\
**Post date:** [November 20, 2023, 4:58pm UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/16 "2023-11-20T16:58:37Z")

</div>

Not sure what it means ?

But I did delete the edit part I previously used, and now

```auto
UPDATE Opal$TempSalesHeader
SET [Your Reference] = {{ $json.reference }}
WHERE [Source Document No_] = '989962';

```

It returns this error `ERROR: Invalid column name 'GHWPIXTSO'.` GHWPIXTSO being the value.

Also, I’m using self-hosted version, maybe that the issue ?

> - Self-hosted users can switch back to RiotTmpl: set `N8N_EXPRESSION_EVALUATOR` to `tmpl`. Refer to [Environment variables](https://docs.n8n.io/hosting/environment-variables/) for more information on configuring self-hosted n8n.

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://community.n8n.io/u/Jonathan)\
**Post date:** [November 21, 2023, 8:04am UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/17 "2023-11-21T08:04:40Z")

</div>

![image](https://europe1.discourse-cdn.com/n8n/original/3X/e/1/e1d4c6cd7cb4de01c12096d0195d04f1eeb4f91e.png)

By looking at the result, $json.reference does get the value so this should work ! Why does it returns an error with column GHWPIXTSO ?!

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [November 21, 2023, 9:07am UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/18 "2023-11-21T09:07:31Z")

</div>

Hey @Jonathan,

It may need `'{{ $json.reference }}'` so that the value is quoted.

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://community.n8n.io/u/Jonathan)\
**Post date:** [November 21, 2023, 9:53am UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/19 "2023-11-21T09:53:21Z")

</div>

Thank you so much for all the help !

Now I can begin (or at least try!) to make more complex workflows

Thanks once more !

---

<div class="post-metadata">

**Author:** ![Jonathan](https://avatars.discourse-cdn.com/v4/letter/j/aeb1de/32.png) [@Jonathan](https://community.n8n.io/u/Jonathan)\
**Post date:** [November 22, 2023, 9:22am UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/20 "2023-11-22T09:22:16Z")

</div>

Hi !

One more question, is it possible to join two or more items into one column ? For example, I’d like to join `'{{ $json.firstname}}'` and `'{{ $json.lastname }}'` together so I get “Firstname Lastname” in my Customer column

Thanks!

I mean without using a merge 🙂

---

<div class="post-metadata">

**Author:** ![Jon](https://dub1.discourse-cdn.com/n8n/user_avatar/community.n8n.io/jon/32/40174_2.png) [@Jon](https://community.n8n.io/u/Jon)\
**Post date:** [November 22, 2023, 10:22am UTC](https://community.n8n.io/t/mysql-to-sql-server/33056/21 "2023-11-22T10:22:12Z")

</div>

Hey @Jonathan,

Should be pretty much what you have put so `'{{ $json.firstname}} {{ $json.lastname }}'` or maybe ‘{{ $json.firstname + " " + $json.lastname }}’

[Next page](https://community.n8n.io/t/mysql-to-sql-server/33056.md?page=2)
