Instead of `dropping` and re-creating the temp table you can `truncate` and reuse it
IF OBJECT_ID('tempdb..#Results') IS NOT NULL
Truncate TABLE #Results
else
CREATE TABLE #Results
(
Company CHAR(3),
StepId TINYINT,
FieldId TINYINT,
)
If you are using `Sql Server 2016` or `Azure Sql Database` then use the below syntax to drop the temp table and recreate it. More info here [**MSDN**][1]
**Syntax**
> DROP TABLE [ IF EXISTS ] [ database_name . [ schema_name ] . |
> schema_name . ] table_name [ ,...n ]
**Query:**
DROP TABLE IF EXISTS #Results
CREATE TABLE #Results
(
Company CHAR(3),
StepId TINYINT,
FieldId TINYINT,
)
[1]:
[To see links please register here]