I recommend always setting a Primary Key in table variables, as in:
Declare @tblStaff Table (
staffID int NOT NULL,
periodBudget money default 0,
stdBudRate money default 0,
nextPeriodBudget money default 0,
daysWorked int
PRIMARY KEY CLUSTERED (staffID))
If the linking field won't be unique, it's simple to force uniqueness.
Declare @tblStaff Table (
rowID int IDENTITY(1,1) NOT NULL,
staffID int NOT NULL,
periodBudget money default 0,
stdBudRate money default 0,
nextPeriodBudget money default 0,
daysWorked int
PRIMARY KEY CLUSTERED (staffID, rowID))
In multi-step procedures that (for example) join derived tables, you can get dramatic increases in speed (I've seen 5 minutes shrink to less than a second) by throwing the derived tables into PKeyed table variables before joining them. Derived tables don't "inherit" any indexing information from their source, so PKeying makes up for that.
This practice also tends to simplify and self-document the code which you (or your successor) will appreciate if the code has to be adjusted (or scavenged from) later.
DZMan1