Click or drag to resize

SA0233 : Temporary table created but not dropped

The topic describes the SA0233 analysis rule.

Message

Temporary table created but not dropped

Description

The rule checks T-SQL code for temporary tables that are created, but not dropped in the same batch.

The temporary tables and objects in general will be cleaned up automatically when the user session ends, but it is a good practice to clean them up after you are not going to use them.

Scope

The rule has a Batch scope and is applied only on the SQL script.

Parameters

Rule has no parameters.

Remarks

The rule does not need Analysis Context or SQL Connection.

Categories

Design Rules

Additional Information

There is no additional info for this rule.

Example Test Script
SQL
 1CREATE TABLE #mail
 2(      
 3        toAddress NVARCHAR( 100 ) ,
 4        fromAddres NVARCHAR( 100 ) ,
 5        subject NVARCHAR( 256 ) ,
 6        body NVARCHAR( 4000 )
 7);
 8
 9SELECT * FROM #mail
10
11INSERT INTO #mail VALUES ('toAddress','fromAddres','subject','body')
12
13DROP TABLE #mail
14
15CREATE TABLE #mail_1
16(      
17        toAddress NVARCHAR( 100 ) ,
18        fromAddres NVARCHAR( 100 ) ,
19        subject NVARCHAR( 256 ) ,
20        body NVARCHAR( 4000 )
21);
22
23INSERT INTO #mail_1 VALUES ('toAddress','fromAddres','subject','body')
24
25SELECT * FROM #mail_1 
26
27SELECT * INTO #table1 FROM table1

Analysis Results

 MessageLineColumn
1SA0233 : Temporary table created but not dropped.1513
2SA0233 : Temporary table created but not dropped.2714
See Also

Other Resources