# Multiple database. Different querys

**URL:** <https://forum.inductiveautomation.com/t/multiple-database-different-querys/20295>\
**Category:** Ignition\
**Created:** [October 22, 2018, 1:57pm UTC](https://forum.inductiveautomation.com/t/multiple-database-different-querys/20295 "2018-10-22T13:57:40Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![t.gegenfurtner](https://avatars.discourse-cdn.com/v4/letter/t/85f322/32.png) [@t.gegenfurtner](https://forum.inductiveautomation.com/u/t.gegenfurtner)\
**Post date:** [October 22, 2018, 1:57pm UTC](https://forum.inductiveautomation.com/t/multiple-database-different-querys/20295/1 "2018-10-22T13:57:40Z")

</div>

Hello together.

Is it possible to save datas from different databases in a new one.

We have 2 foreign databeses. One with energy data and one with order data. The db’s are installed on own server. Both servers are connected with ignition.  
On igniton server we have our “new” database. Here we want to save datas from the other db’s.  
Our partners gave us the permissons for the db connection during ignition.

If i start the designer, I am set the new DB to default DB by the general settings.

Is it possible in a script to select datas from a foreign databse?

I tried SELECT \* FROM [dbname].[tabelname]… but sadly I am get always the error:  
“caused by SQLServerException: Invalid object name [dbname].[tabelname]”

The main problem is to store the data from the energy database. We try to save data from this database  
not in realtime but rather on a timestamp.

Maybe anybody has an idea.

Greetings from bavaria.

PS.

In Designer - Database Query Browser - all querys in each databease are possible,

---

<div class="post-metadata">

**Author:** ![ethomason](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/ethomason/32/43338_2.png) [@ethomason](https://forum.inductiveautomation.com/u/ethomason)\
**Post date:** [October 22, 2018, 2:11pm UTC](https://forum.inductiveautomation.com/t/multiple-database-different-querys/20295/2 "2018-10-22T14:11:00Z")

</div>

Yes it’s possible, most system.db functions have a parameter for the database connection that you can specify. Otherwise it will try and use the default.

For example, [system.db.runQuery](https://docs.inductiveautomation.com/display/DOC79/system.db.runQuery) :

 ![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/a/aae20ffa47fa98be55e99ca17eb74f5ce9682758.png)

If you’re using SQL Query bindings, you will select the database connection here:

![](https://us1.discourse-cdn.com/inductiveautomation/original/2X/a/a6770d7f46b95eb651537787bc98d31419f33ddd.png)

---

<div class="post-metadata">

**Author:** ![t.gegenfurtner](https://avatars.discourse-cdn.com/v4/letter/t/85f322/32.png) [@t.gegenfurtner](https://forum.inductiveautomation.com/u/t.gegenfurtner)\
**Post date:** [October 22, 2018, 2:27pm UTC](https://forum.inductiveautomation.com/t/multiple-database-different-querys/20295/3 "2018-10-22T14:27:55Z")

</div>

Thank you…it works perfect… I was blind …
