# Issue with Nested Query using parameters going from MySQL to MSSQL

**URL:** <https://forum.inductiveautomation.com/t/issue-with-nested-query-using-parameters-going-from-mysql-to-mssql/112040>\
**Category:** Ignition\
**Created:** [November 7, 2025, 4:03pm UTC](https://forum.inductiveautomation.com/t/issue-with-nested-query-using-parameters-going-from-mysql-to-mssql/112040 "2025-11-07T16:03:44Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Curlyandshemp](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@Curlyandshemp](https://forum.inductiveautomation.com/u/Curlyandshemp)\
**Post date:** [November 7, 2025, 4:03pm UTC](https://forum.inductiveautomation.com/t/issue-with-nested-query-using-parameters-going-from-mysql-to-mssql/112040/1 "2025-11-07T16:03:44Z")

</div>

I have an issue with V8.3 reporting. Have an existing application that uses MySQL as the database and customer wants to standardize on Microsoft SQL Server. All queries worked using MySQL as the database source, but I have one nested query that does not work using SQL server as the database source.

This nested query works. The datatable to query is based on the value {tank} returned by the parent query . Datatables are Fermtank1, Fermtank2, and Fermtank3. Parameter 1 is used to determine which datatable to query

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/5/45378ec63d10c29a950fd0b08f0fac0865bfb946.png)

This is the result of the child query in the report Preview Mode

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/f/3f70ef7880924e8a9f0d563c26ce2645ee5a6369.png)

When I convert the child query to use the MSSQL datatables,

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/8/c/8c3acbd1e2fbca746a5752a2cb964254c7a19e2f.png)

An error occurs and the child query fails.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/1/114766ba932865c2ba3194c325cfbf7ae90f64c5.png)

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/4/3/43d7715dde082e66476f80c61d6f1ede88f142f1.png)

The connection SQL1 is valid.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/a/0/a0c3f965ca35750bddb4b2781c9a7b0449201c44.png)

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [November 7, 2025, 4:06pm UTC](https://forum.inductiveautomation.com/t/issue-with-nested-query-using-parameters-going-from-mysql-to-mssql/112040/2 "2025-11-07T16:06:38Z")

</div>

Show the parent query.

---

<div class="post-metadata">

**Author:** ![Curlyandshemp](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@Curlyandshemp](https://forum.inductiveautomation.com/u/Curlyandshemp)\
**Post date:** [November 7, 2025, 4:25pm UTC](https://forum.inductiveautomation.com/t/issue-with-nested-query-using-parameters-going-from-mysql-to-mssql/112040/3 "2025-11-07T16:25:04Z")

</div>

This is the parent Query

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/e/f/efc85dc8fb0b4af6d57d93cb8f68c29d1dadf321.png)

tank is the parameter used in the child query. No issues if child query is MySQL, only an issue if SQL

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [November 7, 2025, 4:26pm UTC](https://forum.inductiveautomation.com/t/issue-with-nested-query-using-parameters-going-from-mysql-to-mssql/112040/4 "2025-11-07T16:26:48Z")

</div>

Hmm OK. Not all syntax is cross compatible between MySQL and MS SQL, but nothing you’ve shown so far is jumping out at me.

Have you tried running the parent query in SSMS with the relevant parameters hard coded in for a test?

---

<div class="post-metadata">

**Author:** ![Curlyandshemp](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@Curlyandshemp](https://forum.inductiveautomation.com/u/Curlyandshemp)\
**Post date:** [November 7, 2025, 4:40pm UTC](https://forum.inductiveautomation.com/t/issue-with-nested-query-using-parameters-going-from-mysql-to-mssql/112040/5 "2025-11-07T16:40:12Z")

</div>

I have come to the conclusion that parent query works, as the value in {tank} is valid when the child query runs using a MySQL database connection.

It seems that the parameterized ( FROM fermtank? ) does not evaluate properly when using a SQL database connection as per the error code “Invalid object name ‘fermtank@P0’. If I hard code the from clause as (FROM fermtank2), the child query works using SQL database connection.

---

<div class="post-metadata">

**Author:** ![Matrix\_Engineering](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/matrix_engineering/32/19781_2.png) [@Matrix\_Engineering](https://forum.inductiveautomation.com/u/Matrix_Engineering)\
**Post date:** [November 7, 2025, 4:43pm UTC](https://forum.inductiveautomation.com/t/issue-with-nested-query-using-parameters-going-from-mysql-to-mssql/112040/6 "2025-11-07T16:43:44Z")

</div>

> [@Curlyandshemp](#):
>
> I have come to the conclusion that parent query works, as the value in {tank} is valid when the **child query runs using a _MySQL_ database connection.**

Is this a typo? Parent might work on MySql but might not on MS SQL.

---

<div class="post-metadata">

**Author:** ![pturmel](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pturmel/32/3295_2.png) [@pturmel](https://forum.inductiveautomation.com/u/pturmel)\
**Post date:** [November 7, 2025, 4:59pm UTC](https://forum.inductiveautomation.com/t/issue-with-nested-query-using-parameters-going-from-mysql-to-mssql/112040/7 "2025-11-07T16:59:34Z")

</div>

MySQL is breaking the rules for value parameters. They are not supposed to work for SQL query **structure** , like table names, column names, or other keywords, as that is a security flaw.

In named queries, you would use curly braces with a **query string** parameter for such things. I don't know if what you are trying is possible (mixing curly brace params with question-mark value params).

---

<div class="post-metadata">

**Author:** ![paul-griffith](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/paul-griffith/32/37249_2.png) [@paul-griffith](https://forum.inductiveautomation.com/u/paul-griffith)\
**Post date:** [November 7, 2025, 5:02pm UTC](https://forum.inductiveautomation.com/t/issue-with-nested-query-using-parameters-going-from-mysql-to-mssql/112040/8 "2025-11-07T17:02:48Z")

</div>

I think it's possible if you use the "Basic SQL Query" style for the data source, instead of the "standard" SQL query.

---

<div class="post-metadata">

**Author:** ![Curlyandshemp](https://avatars.discourse-cdn.com/v4/letter/c/bcef8e/32.png) [@Curlyandshemp](https://forum.inductiveautomation.com/u/Curlyandshemp)\
**Post date:** [November 7, 2025, 5:16pm UTC](https://forum.inductiveautomation.com/t/issue-with-nested-query-using-parameters-going-from-mysql-to-mssql/112040/9 "2025-11-07T17:16:20Z")

</div>

Genius!

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/b/4/b48f2c14cd1bdfae6aa739dc8ea0ba8192059bd0.png)

Query now works, thanks !

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/4/14005d9947a8cfd17aa5df248521cea16ce1fae3.png)
