One of the most often encountered concurrency problems in T-SQL code happens in the Insert or Use scenario in which a new row is inserted if it does not exist yet and afterwards the primary key of the existing or the new row is returned. One of the easiest and safest ways to get this right is provided by the MERGE statement.