• james (2/9/2009)


    So it adds a temp table into memory or on the permamnent media or both? How long does the temp table last?

    There have been times when I want to use a temp table to hold some data for the length of a webpage, but I generally have a table called tempSomethingMeaningful and clear the table when I am done. This way I don't have to worry about setting up the columns every time.

    Temporary tables last as long as the connection that created them. They may be in memory or stored in the database tempdb. See http://msdn.microsoft.com/en-us/library/aa933114(SQL.80).aspx.

    Using temp tables from web pages will depend on how much control you have over the connection. I beleive that a connection is automatically closed at the end of each page rendition (haven't checked) so if you need data to persist from one page to another you need to use permanent tables. Temp tables are mainly used for intermediate results, usually for perfromance reasons; i.e. select some data to a temp table, then do further transformations on the subset of data in the temp table.

    Derek