When I execute a select / Insert query, does SQL Server automatically create an implicit transaction and therefore treat it as a single atomic operation?
Take the following query, which inserts a value into a table if it does not already exist:
INSERT INTO Table1 (FieldA)
SELECT 'newvalue'
WHERE NOT EXISTS (Select * FROM Table1 where FieldA='newvalue')
Is it possible for another user to add a "newvalue" to the table between evaluating the WHERE clause and executing the INSERT clause if it is not explicitly enclosed in a transaction?
source
share