Microsoft SQL Server Use of TEMP Table Local Temp Table

Help us to keep this website almost Ad Free! It takes only 10 seconds of your time:
> Step 1: Go view our video on YouTube: EF Core Bulk Insert
> Step 2: And Like the video. BONUS: You can also share it!

Example

  • Will be available till the current connection persists for the user.

    Automatically deleted when the user disconnects.

    The name should start with # (#temp)

     CREATE TABLE #LocalTempTable(
                    StudentID      int,
                    StudentName    varchar(50), 
                    StudentAddress varchar(150))
    
insert into #LocalTempTable values ( 1, 'Ram','India');

select * from #LocalTempTable

After executing all these statements if we close the query window and open it again and try inserting and select it will show an error message

“Invalid object name #LocalTempTable”


Got any Microsoft SQL Server Question?