MS SQL database
Snapshot Isolation
How to get the current snapshot isolation.
SELECT is_read_committed_snapshot_on, snapshot_isolation_state_desc, snapshot_isolation_state FROM sys.databases WHERE name = '<dbname>'
Power on snapshot isolation
ALTER DATABASE <database> SET SINGLE_USER WITH ROLLBACK IMMEDIATE ; ALTER DATABASE <database> SET allow_snapshot_isolation ON; ALTER DATABASE <database> SET READ_COMMITTED_SNAPSHOT ON; ALTER DATABASE <database> SET MULTI_USER;
Transaction level
How to get the current transaction level.
SELECT CASE transaction_isolation_level WHEN 0 THEN 'Unspecified' WHEN 1 THEN 'ReadUncommitted' WHEN 2 THEN 'ReadCommitted' WHEN 3 THEN 'Repeatable' WHEN 4 THEN 'Serializable' WHEN 5 THEN 'Snapshot' END AS TRANSACTION_ISOLATION_LEVEL FROM sys.dm_exec_sessions where session_id = @@SPI