Fake Temporary Tables and SQL Server 2000

SQL Server introduces several new features that might have implications for whether and how you use fake temporary tables with this new release.

Fernando G. Guerrero

January 23, 2001

1 Min Read
ITPro Today logo in a gray background | ITPro Today

SQL Server 2000 introduces several new features that might have implications for whether and how you use fake temporary tables with this new release.

  1. You can use SQL Server 2000's table data type as an alternative to temporary tables in some cases. Table variables point to table structures in memory, so they produce less overhead than temporary tables. However, table variables are always local to the process that created them, and you can't define a stored procedure parameter as a table data type to send or receive data sets.

  2. Using the new sql_variant data type, you could generalize a fake temporary table definition to hold different data types in a single field depending on the process that you need to trace.

  3. You can create new user-defined functions (UDFs) to return resultsets. Just use a table variable as the return value, and define the UDF as either an inline or multistatement table-valued function. UDFs can be flexible, but they can't directly modify actual data, so their use is limited to READ operations. To use UDFs to implement a fake temporary table strategy that involves data modifications, you need to combine the UDFs with stored procedures, which would handle the actual modifications.

  4. With SQL Server 2000, you can use the CREATE TABLE statement inside triggers. So, you can create a temporary table inside a trigger, if necessary.

Sign up for the ITPro Today newsletter
Stay on top of the IT universe with commentary, news analysis, how-to's, and tips delivered to your inbox daily.

You May Also Like