# Is it possible to connect to a database of another gateway and be able to query from that?

**URL:** <https://forum.inductiveautomation.com/t/is-it-possible-to-connect-to-a-database-of-another-gateway-and-be-able-to-query-from-that/49854>\
**Category:** Ignition\
**Created:** [August 12, 2021, 5:53pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-connect-to-a-database-of-another-gateway-and-be-able-to-query-from-that/49854 "2021-08-12T17:53:38Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [August 12, 2021, 5:53pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-connect-to-a-database-of-another-gateway-and-be-able-to-query-from-that/49854/1 "2021-08-12T17:53:38Z")

</div>

Hello everyone,

I have two gateways and one of them is connected to an SQL server database and my question is, is it possible to connect that database to the 2nd gateway? I do not have access to the SQL server itself so I cannot directly make a connection to the database from the 2nd gateway and the connection should be indirect. I want to be able to query for that database from the 2nd gateway.

Thank you!

---

<div class="post-metadata">

**Author:** ![jgooding](https://avatars.discourse-cdn.com/v4/letter/j/a88e4f/32.png) [@jgooding](https://forum.inductiveautomation.com/u/jgooding)\
**Post date:** [August 12, 2021, 6:17pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-connect-to-a-database-of-another-gateway-and-be-able-to-query-from-that/49854/2 "2021-08-12T18:17:45Z")

</div>

You have to link the gateways (make an connection from each one). You also have to setup permissions for the new server to run sql commands on the other gateway,

[https://docs.inductiveautomation.com/display/DOC81/Gateway+Network](https://docs.inductiveautomation.com/display/DOC81/Gateway+Network)  
[https://inductiveuniversity.com/videos/remote-history-provider/8.1](https://inductiveuniversity.com/videos/remote-history-provider/8.1)

---

<div class="post-metadata">

**Author:** ![pkhoshroo](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/pkhoshroo/32/26801_2.png) [@pkhoshroo](https://forum.inductiveautomation.com/u/pkhoshroo)\
**Post date:** [August 12, 2021, 7:29pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-connect-to-a-database-of-another-gateway-and-be-able-to-query-from-that/49854/4 "2021-08-12T19:29:05Z")

</div>

I actually tested and it worked! Thank you very much!!! However, this is not quite what I want.  
Do you know if it is possible to have that database as a database on the 2nd gateway? Not as a remote tag history provider?  
@jgooding  
I have the database running on the 2nd gateway as a remote history provider, but the information that I am getting from the database is not similar to what I have on the 1st gateway. I do not see the schema that I had anymore. I want to be able to query for that database from the 2nd gateway.

---

<div class="post-metadata">

**Author:** ![Vinodhini\_N](https://avatars.discourse-cdn.com/v4/letter/v/65b543/32.png) [@Vinodhini\_N](https://forum.inductiveautomation.com/u/Vinodhini_N)\
**Post date:** [August 30, 2024, 9:23am UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-connect-to-a-database-of-another-gateway-and-be-able-to-query-from-that/49854/6 "2024-08-30T09:23:37Z")

</div>

I too what that method of accessing remote database of gateway b through gateway network without configuring separately on gateway a

---

<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:** [August 30, 2024, 12:42pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-connect-to-a-database-of-another-gateway-and-be-able-to-query-from-that/49854/7 "2024-08-30T12:42:46Z")

</div>

No, not possible. The best you can do is include a message handler on the gateway that actually has the database that will run named queries on behalf of other gateways, returning the results.

---

<div class="post-metadata">

**Author:** ![Shawn\_Rieger1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/shawn_rieger1/32/57040_2.png) [@Shawn\_Rieger1](https://forum.inductiveautomation.com/u/Shawn_Rieger1)\
**Post date:** [October 24, 2024, 8:43pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-connect-to-a-database-of-another-gateway-and-be-able-to-query-from-that/49854/8 "2024-10-24T20:43:55Z")

</div>

Hi Phil,

This seems to contradict the documentation for a remote tag provider's history access mode settings:

> "This setting dictates how tag history is queried for remote tags. Normally requests are sent through the gateway network, but **if access to the historian database is available, you can choose to query that directly**."

This seems to suggest that if we configure a secondary gateway with an identical database connection, we should be able to use it to query data directly from that server.

I may be misunderstanding something but this is something I'm interested in doing myself.

> **[Tag Providers | Ignition User Manual](https://www.docs.inductiveautomation.com/docs/8.1/platform/tags/tag-providers#remote-tag-provider-1)**
>
> At the highest level of Tag configuration is the Tag Provider. A provider is a Tag database (a collection of Tags) and a name. An Ignition Gateway can have any number of Tag Providers, and therefore the name is used to distinguish which provider a...

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/1/d/1d59d0f50ab3186ded5c83f259cb3e48c62d76fb.png)

---

<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:** [October 24, 2024, 8:52pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-connect-to-a-database-of-another-gateway-and-be-able-to-query-from-that/49854/9 "2024-10-24T20:52:08Z")

</div>

> [@Shawn\_Rieger1](#):
>
> This seems to contradict the documentation for a remote tag provider's history access mode

Neither the original nor the most recent question were about remote tag providers. They were about directly querying a database connection (not tag history) in a remote gateway.

Remote tag provides can divert **historian** queries to a **local** database connection if that local connection contains the desired data, omitting the GAN round trip. Totally different thing.

---

<div class="post-metadata">

**Author:** ![Shawn\_Rieger1](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/shawn_rieger1/32/57040_2.png) [@Shawn\_Rieger1](https://forum.inductiveautomation.com/u/Shawn_Rieger1)\
**Post date:** [October 24, 2024, 9:23pm UTC](https://forum.inductiveautomation.com/t/is-it-possible-to-connect-to-a-database-of-another-gateway-and-be-able-to-query-from-that/49854/10 "2024-10-24T21:23:58Z")

</div>

> [@pturmel](#):
>
> Remote tag provides can divert **historian** queries to a **local** database connection if that local connection contains the desired data, omitting the GAN round trip. Totally different thing.

Thanks for the clarification, you're right. I see the OP's original question was about making SQL queries directly, not about accessing data using remote tag providers.
