December 2013
Intermediate to advanced
1872 pages
153h 31m
English
Temporary tables are commonly used in stored procedures when intermediate results need to be stored in a work table for additional processing. Local temporary tables created in a stored procedure are automatically dropped when the stored procedure exits. Global temporary tables created in a stored procedure still exist after the stored procedure exits until they are explicitly dropped (see Listing 46.13) or the user session in which they were created disconnects from SQL Server.
LISTING 46.13 Using Local and Global Temporary Tables in Stored Procedures
use AdventureWorks2012goset nocount ongoif object_id('temp_test2') is not null drop proc temp_test2goif exists (select ...