#temp tables are available ONLY to the session that created it and are dropped when the session is closed. ##temp tables (global) are available to ALL sessions, but are still dropped when the session that created it is closed and all other references to them are closed.

CREATE TABLE ##Table01
(
	ID	INT IDENTITY(1, 1),
	Note 	VARCHAR(50)
);

SELECT * FROM ##Table01

IF OBJECT_ID('tempdb..##Table01') IS NOT NULL DROP TABLE ##Table01;
Last modified: June 17, 2020

Author

Comments

Write a Reply or Comment