How to insert into a temporary table?

Sjemmie picture Sjemmie · Feb 9, 2010 · Viewed 15.8k times · Source

I'm working with Sybase Central using Adaptive Server Anywhere 9 and I want some examples of how to use tempDB.

How can I insert some records in to a temporary table?

I tried:

select * into TempDB.dba.#testing from testTable

But I got the following error:

Syntax error near '.' on line 1

Answer

mmmmmm picture mmmmmm · Feb 9, 2010

There are two sets of temp tables and you have mixed them up

1) Session related there are access as #table ie

select * into #testing from testTable

This lasts as long as your connection

2) tables in tempdb. These persist until the server gets rebooted.

select * into TempDB.testing from testTable

See sybase docs for more info ASE