# Taking results from SQL Query and sending it to a Session Custom Property

**URL:** <https://forum.inductiveautomation.com/t/taking-results-from-sql-query-and-sending-it-to-a-session-custom-property/64548>\
**Category:** Ignition\
**Tags:** perspective\
**Created:** [September 27, 2022, 4:34pm UTC](https://forum.inductiveautomation.com/t/taking-results-from-sql-query-and-sending-it-to-a-session-custom-property/64548 "2022-09-27T16:34:18Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![CMuecke](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@CMuecke](https://forum.inductiveautomation.com/u/CMuecke)\
**Post date:** [September 27, 2022, 4:34pm UTC](https://forum.inductiveautomation.com/t/taking-results-from-sql-query-and-sending-it-to-a-session-custom-property/64548/1 "2022-09-27T16:34:18Z")

</div>

I am able to grab data from a SQL Query and have it show up in a table in Perspective. I am able to take the data from the Table and copy it to a Session Custom Property.

Is it possible to do this all in one step? With a press of a button?

---

<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 27, 2022, 7:18pm UTC](https://forum.inductiveautomation.com/t/taking-results-from-sql-query-and-sending-it-to-a-session-custom-property/64548/2 "2022-09-27T19:18:43Z")

</div>

Try instead to apply the SQL query binding to the session custom property.  
Then bind the table data to _that_.

---

<div class="post-metadata">

**Author:** ![craigb](https://avatars.discourse-cdn.com/v4/letter/c/9f8e36/32.png) [@craigb](https://forum.inductiveautomation.com/u/craigb)\
**Post date:** [September 27, 2022, 7:51pm UTC](https://forum.inductiveautomation.com/t/taking-results-from-sql-query-and-sending-it-to-a-session-custom-property/64548/3 "2022-09-27T19:51:28Z")

</div>

In the button action performed…

```auto
	self.custom.Result = system.db.runQuery("SELECT * FROM equipment")

```

That sends the dataset to the custom property ‘Result’ on the button, which then can be be sent to the session custom property bidirectional.

 ![image](https://us1.discourse-cdn.com/inductiveautomation/original/3X/3/6/36c280ff448390cbb5d0cd24f0df1a59f3e4897d.png)

---

<div class="post-metadata">

**Author:** ![CMuecke](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@CMuecke](https://forum.inductiveautomation.com/u/CMuecke)\
**Post date:** [September 27, 2022, 8:51pm UTC](https://forum.inductiveautomation.com/t/taking-results-from-sql-query-and-sending-it-to-a-session-custom-property/64548/4 "2022-09-27T20:51:29Z")

</div>

My goal is to create a copy of the table that is retrieved from the Database.

Order of operation may be…

Grab data from Database.

Send it to the Session Custom Properties. If I make changes, I don’t want it to change the data in the database until I send it back.

---

<div class="post-metadata">

**Author:** ![Kevin.Herron](https://sea1.discourse-cdn.com/inductiveautomation/user_avatar/forum.inductiveautomation.com/kevin.herron/32/7259_2.png) [@Kevin.Herron](https://forum.inductiveautomation.com/u/Kevin.Herron)\
**Post date:** [September 27, 2022, 10:32pm UTC](https://forum.inductiveautomation.com/t/taking-results-from-sql-query-and-sending-it-to-a-session-custom-property/64548/5 "2022-09-27T22:32:15Z")

</div>

> [@CMuecke](#):
>
> If I make changes, I don’t want it to change the data in the database until I send it back.

You're in luck, because that's not how it works.

The query result dataset is an independent copy, and the only way anything goes back to the database is if you script up an insert or update query.

---

<div class="post-metadata">

**Author:** ![CMuecke](https://avatars.discourse-cdn.com/v4/letter/c/df705f/32.png) [@CMuecke](https://forum.inductiveautomation.com/u/CMuecke)\
**Post date:** [September 28, 2022, 12:00pm UTC](https://forum.inductiveautomation.com/t/taking-results-from-sql-query-and-sending-it-to-a-session-custom-property/64548/6 "2022-09-28T12:00:31Z")

</div>

Ahh. So I was worried about something I did not need to be worried about. Thank you everyone for your help!
