# Db tag binding to a sql query - can't specify the database?

**URL:** <https://forum.inductiveautomation.com/t/db-tag-binding-to-a-sql-query-cant-specify-the-database/3345>\
**Category:** Ignition\
**Created:** [September 27, 2011, 10:11am UTC](https://forum.inductiveautomation.com/t/db-tag-binding-to-a-sql-query-cant-specify-the-database/3345 "2011-09-27T10:11:54Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![mazeyrat](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/mazeyrat/32/10955_2.png) [@mazeyrat](https://forum.inductiveautomation.com/u/mazeyrat)\
**Post date:** [September 27, 2011, 10:11am UTC](https://forum.inductiveautomation.com/t/db-tag-binding-to-a-sql-query-cant-specify-the-database/3345/1 "2011-09-27T10:11:54Z")

</div>

How can we indicate the database to perform the sql select in the expression/binding of a db tag with the sql query mode ???

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [September 27, 2011, 2:53pm UTC](https://forum.inductiveautomation.com/t/db-tag-binding-to-a-sql-query-cant-specify-the-database/3345/2 "2011-09-27T14:53:28Z")

</div>

Right now you can only specify one database connection per SQLTags provider. That is why the database dropdown box is disabled. You can change the default database in the Ignition Gateway config section under SQLTags \> Realtime by editing the default provider.

You can create multiple SQLTags (internal) providers that you can store separate tags in. Each provider can have a different default database associated with it.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [September 27, 2011, 3:09pm UTC](https://forum.inductiveautomation.com/t/db-tag-binding-to-a-sql-query-cant-specify-the-database/3345/3 "2011-09-27T15:09:48Z")

</div>

Aha! That’s a piece I was missing in one of my back burner projects. I’d been getting around it by expressions and scripts, but this will help remove a few smoke and mirrors…

Does it have to be an internal provider?

---

<div class="post-metadata">

**Author:** ![Travis.Cox](https://avatars.discourse-cdn.com/v4/letter/t/b9bd4f/32.png) [@Travis.Cox](https://forum.inductiveautomation.com/u/Travis.Cox)\
**Post date:** [September 27, 2011, 3:19pm UTC](https://forum.inductiveautomation.com/t/db-tag-binding-to-a-sql-query-cant-specify-the-database/3345/4 "2011-09-27T15:19:47Z")

</div>

No, it doesn’t have to be an internal one. You can also use the database driving provider.

---

<div class="post-metadata">

**Author:** ![JordanCClark](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/jordancclark/32/83362_2.png) [@JordanCClark](https://forum.inductiveautomation.com/u/JordanCClark)\
**Post date:** [September 27, 2011, 3:32pm UTC](https://forum.inductiveautomation.com/t/db-tag-binding-to-a-sql-query-cant-specify-the-database/3345/5 "2011-09-27T15:32:27Z")

</div>

Thanks!

---

<div class="post-metadata">

**Author:** ![Colby.Clegg](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/colby.clegg/32/3282_2.png) [@Colby.Clegg](https://forum.inductiveautomation.com/u/Colby.Clegg)\
**Post date:** [September 27, 2011, 5:50pm UTC](https://forum.inductiveautomation.com/t/db-tag-binding-to-a-sql-query-cant-specify-the-database/3345/6 "2011-09-27T17:50:04Z")

</div>

A few things about this:

1. In 7.3, you can now specify different database connections for expression tags in internal providers.

2. You could always do this, by using “expression mode” instead of “sql mode”, and the expression functions “runScalarQuery”,“runUpdateQuery”, etc. Those functions look like “(query, [db connection])”.

Regards,
