Creating a Primary Key on a temp table - When?
问题 I have a stored procedure that is working with a large amount of data. I have that data being inserted in to a temp table. The overall flow of events is something like CREATE #TempTable ( Col1 NUMERIC(18,0) NOT NULL, --This will not be an identity column. ,Col2 INT NOT NULL, ,Col3 BIGINT, ,Col4 VARCHAR(25) NOT NULL, --Etc... -- --Create primary key here? ) INSERT INTO #TempTable SELECT ... FROM MyTable WHERE ... INSERT INTO #TempTable SELECT ... FROM MyTable2 WHERE ... -- -- ...or create