Skip to content

Instantly share code, notes, and snippets.

@LitKnd
Created March 22, 2019 21:02
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save LitKnd/ae231bcd669a9a6c2cc23aacc0429974 to your computer and use it in GitHub Desktop.
Save LitKnd/ae231bcd669a9a6c2cc23aacc0429974 to your computer and use it in GitHub Desktop.
# Note: technically snapshot isolation can be in a 'pending' state
# In this state it is waiting for open transactions to complete before the setting turns on
# This script does not check for that state, it simply looks to see if it's off and enables it in that case
IF
(
SELECT snapshot_isolation_state_desc
FROM sys.databases
WHERE database_id = DB_ID()
) = 'OFF'
BEGIN
PRINT 'Enabling snapshot isolation...';
ALTER DATABASE CURRENT SET ALLOW_SNAPSHOT_ISOLATION ON;
END;
ELSE
PRINT 'Snapshot isolation not set to off, moving on...';
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment