# Named query select statement throws com.microsoft.sqlserver.jdbc.SQLServerException: The index 1 is out of range

**URL:** <https://forum.inductiveautomation.com/t/named-query-select-statement-throws-com-microsoft-sqlserver-jdbc-sqlserverexception-the-index-1-is-out-of-range/47561>\
**Category:** Ignition\
**Tags:** namedqueries\
**Created:** [June 8, 2021, 3:52pm UTC](https://forum.inductiveautomation.com/t/named-query-select-statement-throws-com-microsoft-sqlserver-jdbc-sqlserverexception-the-index-1-is-out-of-range/47561 "2021-06-08T15:52:54Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![David](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@David](https://forum.inductiveautomation.com/u/David)\
**Post date:** [June 8, 2021, 3:52pm UTC](https://forum.inductiveautomation.com/t/named-query-select-statement-throws-com-microsoft-sqlserver-jdbc-sqlserverexception-the-index-1-is-out-of-range/47561/1 "2021-06-08T15:52:54Z")

</div>

Very straightforward select query that accepts one value paramter (string) results in  
**com.microsoft.sqlserver.jdbc.SQLServerException: The index 1 is out of range.**

Here is my query:  
SELECT DISTINCT itemClassId, itemType + ’ – ’ + itemSubType as label  
from imItemClass  
WHERE itemSubType IS NOT NULL  
AND itemCategory = ‘:itemCategory’  
order by label

And the parameter itemCategory is a type = value and datatype = string

---

<div class="post-metadata">

**Author:** ![David](https://avatars.discourse-cdn.com/v4/letter/d/aeb1de/32.png) [@David](https://forum.inductiveautomation.com/u/David)\
**Post date:** [June 8, 2021, 3:59pm UTC](https://forum.inductiveautomation.com/t/named-query-select-statement-throws-com-microsoft-sqlserver-jdbc-sqlserverexception-the-index-1-is-out-of-range/47561/2 "2021-06-08T15:59:28Z")

</div>

Solved it:

AND itemCategory = ‘:itemCategory’  
should instead read:  
**AND itemCategory = :itemCategory** – no quotes
