MSSQL PROCEDURE

Temporary Stored Procedures

Local temporary stored procedure

Available only in the current session and is dropped when the session is closed.

CREATE OR ALTER PROCEDURE #MyProc AS ...

Global temporary stored procedure

Available in all sessions and is dropped when the session of the user that created it is closed.

CREATE OR ALTER PROCEDURE ##MyProc AS ...

TEMPDB stored procedure

Available in all sessions and is only dropped when SQL Server is restarted (at which point TEMPDB will be recreated thus wiping out your procedure).

USE tempdb

GO

CREATE OR ALTER PROCEDURE dbo.MyProc AS ...

Bibliography