# system.db.runPrepQuery View Resulting SQL

**URL:** <https://forum.inductiveautomation.com/t/system-db-runprepquery-view-resulting-sql/86911>\
**Category:** Ignition\
**Tags:** database, ignition81, scripting\
**Created:** [March 6, 2024, 4:48pm UTC](https://forum.inductiveautomation.com/t/system-db-runprepquery-view-resulting-sql/86911 "2024-03-06T16:48:49Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jackson\_Lancaster](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@Jackson\_Lancaster](https://forum.inductiveautomation.com/u/Jackson_Lancaster)\
**Post date:** [March 6, 2024, 4:48pm UTC](https://forum.inductiveautomation.com/t/system-db-runprepquery-view-resulting-sql/86911/1 "2024-03-06T16:48:49Z")

</div>

Is there any way to see the resulting SQL that is created, with the parameters included, when calling system.db.runPrepQuery or is there another function that can do that?

---

<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:** [March 6, 2024, 4:58pm UTC](https://forum.inductiveautomation.com/t/system-db-runprepquery-view-resulting-sql/86911/2 "2024-03-06T16:58:13Z")

</div>

No, but...why? It's just the query with any parameters replaced.

You can set the `gateway.database.Selects` (or `.Updates`) logger to TRACE and see _every_ query being issued by Ignition.

I'm curious what you're trying to diagnose/prove/whatever with this information, though.

---

<div class="post-metadata">

**Author:** ![Jackson\_Lancaster](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@Jackson\_Lancaster](https://forum.inductiveautomation.com/u/Jackson_Lancaster)\
**Post date:** [March 6, 2024, 5:03pm UTC](https://forum.inductiveautomation.com/t/system-db-runprepquery-view-resulting-sql/86911/3 "2024-03-06T17:03:17Z")

</div>

> [@paul-griffith](#):
>
> gateway.database.Selects

So I just tried that, but my query has so many parameters that the debug log doesnt show all of them.

Im trying to troubleshoot a MERGE database statement, and I'm to the point that I need to see the actual merge statement that is generated. There is a way to view this via SQL Profiler, but in my case its a bit hard to get this setup.

So Im looking for a way to do it in Ignition.

---

<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:** [March 6, 2024, 5:07pm UTC](https://forum.inductiveautomation.com/t/system-db-runprepquery-view-resulting-sql/86911/4 "2024-03-06T17:07:16Z")

</div>

> [@Jackson\_Lancaster](#):
>
> my query has so many parameters that the debug log doesnt show all of them.

😬  
That smells like a bad pattern to me, but giving the benefit of the doubt...  
Is the log output truly truncated, or is it just that the web UI isn't showing everything? What about the wrapper log, or if you open an exported system log in [Kindling](https://github.com/inductiveautomation/kindling)?

Looking at the _input_ query should be possible with some logging in your RDBMS; I'm not sure if that's what you mean by SQL profiler, but that's probably going to be the best option. If your database connection isn't set to use encrypted traffic, you could maybe set up Wireshark (and hope it has the ability to decode your DB's wire protocol?)

---

<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:** [March 6, 2024, 5:11pm UTC](https://forum.inductiveautomation.com/t/system-db-runprepquery-view-resulting-sql/86911/5 "2024-03-06T17:11:24Z")

</div>

Is there any chance you are tripping on the limit for parameters? Some DBs only allow a couple thousand. (MS SQL Server, in particular.)

---

<div class="post-metadata">

**Author:** ![Jackson\_Lancaster](https://avatars.discourse-cdn.com/v4/letter/j/ebca7d/32.png) [@Jackson\_Lancaster](https://forum.inductiveautomation.com/u/Jackson_Lancaster)\
**Post date:** [March 6, 2024, 5:23pm UTC](https://forum.inductiveautomation.com/t/system-db-runprepquery-view-resulting-sql/86911/6 "2024-03-06T17:23:34Z")

</div>

Very good point. Im at 1098 on the query that is failing
