/* Populate the NextKeyValue table. Set all the initial values to 0 so the first key generated for each key type will be 1. */ INSERT INTO NextKeyValue (KeyName, KeyValue) VALUES ("EmployeeId", 1) INSERT INTO NextKeyValue (KeyName, KeyValue) VALUES ("DepartmentId", 1) INSERT INTO NextKeyValue (KeyName, KeyValue) VALUES ("AccountId", 1) /* Now run the following scripts from separate connections */ -- Connection #1 begin tran exec GetNextKeyValue "EmployeeId" --Connection #2 sp_who begin tran exec GetNextKeyValue "DepartmentId" --Connection #3 begin tran exec GetNextKeyValue "AccountId" --Connection #4 begin tran exec GetNextKeyValue "AccountId"