i'm using in some stored procedures a # table that contains a discreet
number of records (about 70000). I choose to add a primary key to
encrease performances ad that it happens. The code i used is the below:
alter table #tmptree ADD
constraint [pk_tmptree] primary key
If i try to execute the procedure twice at the same time, sql server
warn me that the object [pk_tmptree] already exist.
I avoid the problem, generating a guiid for every primary key generated.
The code is this:
set rndmid = substring(convert(varchar(64),NewID()),0,8)
set pkeystr =