Saturday, January 11, 2025
HomeProgrammingHow to create temp table using Create statement in SQL

How to create temp table using Create statement in SQL

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:

sql
CREATE TABLE #TempTable (
ID INT,
Name VARCHAR(50)
);

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.

RELATED ARTICLES
0 0 votes
Article Rating

Leave a Reply

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
- Advertisment -

Most Popular

Recent Comments

0
Would love your thoughts, please comment.x
()
x