# Query Builder Issue

**URL:** <https://forum.inductiveautomation.com/t/query-builder-issue/107045>\
**Category:** Ignition\
**Tags:** ignition81, perspective\
**Created:** [June 4, 2025, 7:19pm UTC](https://forum.inductiveautomation.com/t/query-builder-issue/107045 "2025-06-04T19:19:47Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Ros\_Alexander1](https://avatars.discourse-cdn.com/v4/letter/r/db5fbb/32.png) [@Ros\_Alexander1](https://forum.inductiveautomation.com/u/Ros_Alexander1)\
**Post date:** [June 4, 2025, 7:19pm UTC](https://forum.inductiveautomation.com/t/query-builder-issue/107045/1 "2025-06-04T19:19:47Z")

</div>

I'm running into an odd issue. I have multiple named queries that work as intended. When using certain tables I get an error: com.microsoft.sqlserver.jdbc.SQLServerException: The index 2 is out of range.

Script:

```python

--This is from the query builder and works as intended.
--SELECT Arms_Electronic_Traveler.*
--FROM Arms_Electronic_Traveler
--WHERE Arms_Electronic_Traveler.Arms_Updated_Job_Num = :travelerBarcode

--When I write this I get the error I posted above. 
SELECT dbo.Arms_Electronic_Traveler.*
FROM dbo.Arms_Electronic_Traveler
WHERE dbo.Arms_Electronic_Traveler.Arms_Updated_Job_Num = :travelerBarcode

```

---

<div class="post-metadata">

**Author:** ![michael.flagler](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/michael.flagler/32/26272_2.png) [@michael.flagler](https://forum.inductiveautomation.com/u/michael.flagler)\
**Post date:** [June 4, 2025, 7:22pm UTC](https://forum.inductiveautomation.com/t/query-builder-issue/107045/2 "2025-06-04T19:22:47Z")

</div>

Personally, I think your query should be simplified to this:

```python
SELECT *
FROM Arms_Electronic_Traveler
WHERE Arms_Updated_Job_Num = :travelerBarcode

```

No need for the table name in everything, and I've never used dbo prefix on anything either.

If you're joining multiple tables, that's where you start needing to use table names, but even then I shorten them to something like this:

```python
SELECT aet.*
FROM Arms_Electronic_Traveler aet
WHERE aet.Arms_Updated_Job_Num = :travelerBarcode

```

If you really want to include the schema in it, then try this and see if it works:

```python
SELECT aet.*
FROM dbo.Arms_Electronic_Traveler aet
WHERE aet.Arms_Updated_Job_Num = :travelerBarcode

```

---

<div class="post-metadata">

**Author:** ![simeonw](https://avatars.discourse-cdn.com/v4/letter/s/4da419/32.png) [@simeonw](https://forum.inductiveautomation.com/u/simeonw)\
**Post date:** [June 4, 2025, 7:29pm UTC](https://forum.inductiveautomation.com/t/query-builder-issue/107045/3 "2025-06-04T19:29:17Z")

</div>

Sometimes the comments can cause issues. Are you leaving that commented query in when you run it?

This gives me the same error:

```python
--SELECT dbo.Asset.*
--FROM dbo.Asset
--WHERE dbo.Asset.ID = :test

SELECT dbo.Asset.*
FROM dbo.Asset
WHERE dbo.Asset.ID = :test

```

This does not:

```python
--SELECT dbo.Asset.*
--FROM dbo.Asset
--WHERE dbo.Asset.ID = 1

SELECT dbo.Asset.*
FROM dbo.Asset
WHERE dbo.Asset.ID = :test

```

Specifically, I don't think it likes having the parameter **:test** in a comment. So if you must keep the commented query, remove **:travelerBarcode** from the comment.

---

<div class="post-metadata">

**Author:** ![Ros\_Alexander1](https://avatars.discourse-cdn.com/v4/letter/r/db5fbb/32.png) [@Ros\_Alexander1](https://forum.inductiveautomation.com/u/Ros_Alexander1)\
**Post date:** [June 4, 2025, 7:42pm UTC](https://forum.inductiveautomation.com/t/query-builder-issue/107045/4 "2025-06-04T19:42:22Z")

</div>

I believe that is what the issue was. Once I removed the comments, or the parameter from the comment, the issue was no longer present.
