Table variables (
DECLARE @t TABLE) are visible only to the connection that creates it, and are deleted when the batch or stored procedure ends.
Local temporary tables (
CREATE TABLE #t) are visible only to the connection that creates it, and are deleted when the connection is closed.
Global temporary tables (
CREATE TABLE ##t) are visible to everyone, and are deleted when all connections that have referenced them have closed.
Tempdb permanent tables (
USE tempdb CREATE TABLE t) are visible to everyone, and are deleted when the server is restarted.
Best Practices of Writing SQL Queries; SQL Server Query Optimization; SQL Server Performance Tuning; SQL Server Query Performance Optimization; Temporary table in SQL
714 4/25/2017 10:48:56 PM