In SQL, a temporary table is created using the CREATE TABLE
statement with a #
(local) or ##
(global) prefix for the table name. A temporary table is session-specific and will be automatically dropped once the session ends.
Example of creating a temporary table:
This creates a local temporary table named #TempTable
. You can perform INSERT
, SELECT
, UPDATE
, and DELETE
operations on it within the session. For global temporary tables, use ##TempTable
, which can be accessed across different sessions until the server is restarted.