Temp Table Name

  • Is there a way to have SQL Server automatically generate a unique temp table name?

  • If you are using local temp tables then SQL Server ensures each name is unique. 

     

    If you are using global temp tables then you must ensure the names are unique.

     

    How are you planning to use the temp tables?

    Robert W. Marda
    Billing and OSS Specialist - SQL Programmer
    MCL Systems

  • If you are using local temporary table, SQL Server will automatically add the timestamp (the time temp table created) at the back of the orginal table name. Try to avoid global temporary table if possible, and replace it with temporary table instead. Global temporary table will reside at the MSDB until all connections to it totally disconnect, and this situation seldom happen in real production time.

    Remember to destroy (drop) the temporary table after use, even when you are using local temporary table because it is resource "greed".

    Robert's is correct. Tell us more how u going to use it and why...

     



    Regards,
    kokyan

  • My question has more to do with client code.  Let's say I'm creating business logic in VB and I need to create a temporary table.  I want to make sure that the table name is unique.

     

  • I would try using a local temp table.  It should work for you as long as only one connection (the one that created the temp table) needs access to that temp table.

    Robert W. Marda
    Billing and OSS Specialist - SQL Programmer
    MCL Systems

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply