I have a bunch of sync issues. But here is the beginning of them and i hope its a simple one. I have multi-threaded program trying to insert sql records to a table with an autogenerated key. When i insert the record, I would like to know the key of that record for later updates. i noticed there is a merge statement, but it wasn't clear to me if it gurantees a "lock" with its statements. I am not sure of the syntax, but if i use a merge statement to insert a record, and, (i think), get identiy, could two threads call the same merge statement at the same time and the first in line inserts the record, and before it executes the identity statement, the other inserts its record, and now the first gets the second record's identity since it was inserted before its, (the first thread's), identity statement was performed. ...Or, what is the best way to do what i am trying to do. Not sure this makes any difference, but i am using SQL Compact Edition.