I would like an explanation of a SQL script

In mssql what does the # do/mean in front of the name of the file that I am inserting into in the line below?
SELECT * INTO #Data
I looked in the database and could not find the file called #Data but when I did the following it gave me data:
SELECT * FROM #Data
How does this work and is this a temporary file somewhere? If so where do I find it?

Represents a temporary table.

There get created in tempdb database.

1 Like

Thanks for the help, I thought that was the case. How do I delete the file then?

Its a table and you can delete it using a drop command.
drop table #tablename

1 Like

Excellent, thanks for the help.

Also, a #temp table will be automatically dropped once you disconnect the session where you created it.

2 Likes

Thanks, I was worried that it would hang around, so I wanted to delete it.