0 votes
1 view
in SQL by (36.2k points)

Can you please explain how to create a temporary table in SQL?

1 Answer

0 votes
by (87.5k points)

Temporary tables are used to store the intermediate results so that they can be accessed multiple times. We can create temporary tables using SELECT INTO statement and the name of the temporary table must start with #. Here is the syntax to create a temporary table in SQL:

SELECT columns_list

INTO #temporary_table

FROM table_name

Here is the example to create a temporary table in SQL:


INTO #temp_table

FROM Employee

WHERE salary > 20000

In the above example, we are creating a temporary table named temp_table with the details of the employees whose salaries are greater than 20000.

In case you want to learn SQL, then sign up for this SQL training course by Intellipaat that provides instructor-led training, certification, and also job assistance.

Related questions

Welcome to Intellipaat Community. Get your technical queries answered by top developers !