# DB2 Global Temp Table

**URL:** <https://forums.toadworld.com/t/db2-global-temp-table/38244>\
**Category:** Toad Data Point & Toad Intelligence Central\
**Created:** [August 25, 2016, 12:06pm UTC](https://forums.toadworld.com/t/db2-global-temp-table/38244 "2016-08-25T12:06:14Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![Dagra](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@Dagra](https://forums.toadworld.com/u/Dagra)\
**Post date:** [August 25, 2016, 12:06pm UTC](https://forums.toadworld.com/t/db2-global-temp-table/38244/1 "2016-08-25T12:06:14Z")

</div>

I have a situation where I have a list of ID’s that reside on a SQLServer, and I need to match those ID’s to records in a table on a DB2 server. I have created a global temp table using the below code on the DB2 server, but when I try to run the import wizard to import my query from SQLServer, I can not find my temp table anywhere. I do this regularly between SQLServers that I can not open row set between and have to adjust to show the tempdb. This did not seem to be the case for DB2. I am new to DB2 so any help you can provide is appreciated.

This is how I am creating the temp table:

DECLARE GLOBAL TEMPORARY TABLE SESSION.TempTable

(

ID VARCHAR(21) NOT NULL

) ON COMMIT PRESERVE ROWS

---

<div class="post-metadata">

**Author:** ![Debbie\_Peabody](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/debbie_peabody/32/18_2.png) [@Debbie\_Peabody](https://forums.toadworld.com/u/Debbie_Peabody)\
**Post date:** [August 26, 2016, 3:26pm UTC](https://forums.toadworld.com/t/db2-global-temp-table/38244/2 "2016-08-26T15:26:22Z")

</div>

I believe that type of temp table is only retained for the life of the session. When using import we use multiple connections, so I suspect the table is not in the same open session. Can you create a table, insert and then drop manually?

---

<div class="post-metadata">

**Author:** ![Dagra](https://avatars.discourse-cdn.com/v4/letter/d/b9bd4f/32.png) [@Dagra](https://forums.toadworld.com/u/Dagra)\
**Post date:** [September 2, 2016, 7:28am UTC](https://forums.toadworld.com/t/db2-global-temp-table/38244/3 "2016-09-02T07:28:47Z")

</div>

No unfortunately my access is only read only and I do not have power user access to create a table to temporarily store the data. With SQL Server connections I can create global temps and import data by finding the tempdb database. It sounds like sessions in DB2 are not the same as this.

---

<div class="post-metadata">

**Author:** ![Debbie\_Peabody](https://sea1.discourse-cdn.com/quest/user_avatar/forums.toadworld.com/debbie_peabody/32/18_2.png) [@Debbie\_Peabody](https://forums.toadworld.com/u/Debbie_Peabody)\
**Post date:** [September 2, 2016, 7:46pm UTC](https://forums.toadworld.com/t/db2-global-temp-table/38244/4 "2016-09-02T19:46:56Z")

</div>

why not use a cross-connection query to join the data?

See these videos

[http://www.toadworld.com/products/toad-data-point/m/media-library/1319](http://www.toadworld.com/products/toad-data-point/m/media-library/1319)

[http://www.toadworld.com/products/toad-data-point/m/media-library/1317](http://www.toadworld.com/products/toad-data-point/m/media-library/1317)
