SQL Server: temporary tables and constraint names
Update. Since the version 2016 SQL Server supports anonymous constraint declaration:
CREATE TABLE #temp_table (
id1 int NOT NULL,
id2 int NOT NULL,
name1 nvarchar(100),
name2 nvarchar(100),
PRIMARY KEY (id1, id2),
UNIQUE (name1, name2)
);
For earlier versions the solution is below.
Local temporary tables are isolated in the scope …