# Switching default database in named queries

**URL:** <https://forum.inductiveautomation.com/t/switching-default-database-in-named-queries/78904>\
**Category:** Ignition\
**Created:** [September 8, 2023, 11:11am UTC](https://forum.inductiveautomation.com/t/switching-default-database-in-named-queries/78904 "2023-09-08T11:11:15Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 8, 2023, 11:11am UTC](https://forum.inductiveautomation.com/t/switching-default-database-in-named-queries/78904/1 "2023-09-08T11:11:15Z")

</div>

I'm developing an application to retrieve data from an SQL Express server running on the machine's HMI. I have some of the named queries operational at this stage.1

I have a second identical machine running its own instance of SQL Express and will set up a separate database connection for it.

Question: what is the smart way to switch database connections (or switch the application's default database) when using named queries? (Any Perspective client will be looking at one machine or the other with selection by user.)

* * *

1 Old SQL server driver / connection setup here:

> [@SQL Express 2005 database connection ideas?](https://forum.inductiveautomation.com/t/sql-express-2005-database-connection-ideas/78728/17):
>
> Yes and yes. slight_smile

---

<div class="post-metadata">

**Author:** ![lrose](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/lrose/32/62724_2.png) [@lrose](https://forum.inductiveautomation.com/u/lrose)\
**Post date:** [September 8, 2023, 11:26am UTC](https://forum.inductiveautomation.com/t/switching-default-database-in-named-queries/78904/2 "2023-09-08T11:26:03Z")

</div>

> [@Transistor](#):
>
> Question: what is the smart way to switch database connections

The only way that I know of is to use the database parameter. I don't rely on default project settings for databases (or tag providers).

1. Providing a these by parameter makes the call explicit and more readable for future programmers.
2. I work in an environment where someone other than me may change the project defaults, so this ensures my code doesn't break.

---

<div class="post-metadata">

**Author:** ![Transistor](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/transistor/32/3380_2.png) [@Transistor](https://forum.inductiveautomation.com/u/Transistor)\
**Post date:** [September 8, 2023, 11:35am UTC](https://forum.inductiveautomation.com/t/switching-default-database-in-named-queries/78904/3 "2023-09-08T11:35:01Z")

</div>

Duh! There's a **parameter** option in the Database Connection dropdown! I've been doing this for years and never noticed (but hadn't needed to).

[https://docs.inductiveautomation.com/display/DOC81/Named+Query+Workspace#NamedQueryWorkspace-Authoring](https://docs.inductiveautomation.com/display/DOC81/Named+Query+Workspace#NamedQueryWorkspace-Authoring)

Thanks.
