Question : Create Table statement

Hi,

I brand new to Sybase and the specific flavour of SQL.

What is the syntax for creating a temporary table from a select statement. That is a temp table is created already populated with rows from a select statement...?

Thanks Ian

Answer : Create Table statement

Work tables are something different yet; they do not have metadata in the system tables at all.

The #mytable temp tables are, among other things, private by design.  You cannot grant access to them to another user, or even another process, even if it is the same login.  The hash of the name to make them unique is done in part because the metadata for a #temptable is actually present in the tempdb system tables.  Even if you go and dig out the hashed name in tempdb, you still cannot access them.

Using #temptables and allowing Sybase to clean them up is perfectly acceptable in the context of stored procedures.  The only times you need to worry about explicitly droping them (the truncate is unncessary) is if you have a long running multi-step stored procedure and your temp tables are large enough that you need to worry about freeing up space in tempdb OR when you create a #temptable at the connection level and are finished with it.  In that case, you definetly want to drop it when you are done with it so that it does not hang around for the entire life of the session.

Regards,
Bill
Random Solutions  
 
programming4us programming4us