Does SQL Server include a choice ... Putting queries in an implicit transaction?

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?

+2
source share
3 answers

. Transaction , - . , . . , - , . , ... insert , , , ... INSERT .

+5
, . READ UNCOMMITTED, , . READ COMMITTED ( ), REPEATABLE READ SERIALIZABLE .
+2

. :

: IF

+2

All Articles