Click or drag to resize

SA0264 : Temporary table created but not used as table source

The topic describes the SA0264 analysis rule.

Message

Temporary table created but not used as table source

Description

The rule checks T-SQL code for temporary tables created, but not used as a table source in any FROM clause of following SELECT, UPDATE, DELETE or MERGE statements.

Review the code and the temporary table usages and remove it if is not really needed.

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, New Rules

Additional Information

There is no additional info for this rule.

Example Test Script
SQL
 1CREATE TABLE #Greeting
 2(
 3GreetingId INT IDENTITY (1,1) PRIMARY KEY,
 4Message nvarchar(255) NOT NULL,
 5)
 6
 7SELECT * INTO #Greeting2 FROM dbo.Greeting
 8
 9INSERT INTO #Greeting (Message) 
10SELECT 'Hello!'
11UNION ALL 
12SELECT 'Hi!'
13UNION ALL
14SELECT 'Hello, world!'
15
16DELETE  #Greeting WHERE GreetingId = 3
17
18-- SELECT * FROM #Greeting g WHERE g.Message like 'Hello%'

Analysis Results

 MessageLineColumn
1SA0264 : Temporary table created but not used as table source.113
2SA0264 : Temporary table created but not used as table source.714
See Also

Other Resources