Saturday, July 18, 2009

Enable Snapshots

Very useful to avoid lockouts with DBs being accessed and updated...:


ALTER DATABASE YourDatabase
SET SINGLE_USER WITH NOWAIT
GO
ALTER DATABASE YourDatabase
SET ALLOW_SNAPSHOT_ISOLATION ON
GO
ALTER DATABASE YourDatabase
SET READ_COMMITTED_SNAPSHOT ON
GO
ALTER DATABASE YourDatabase
SET MULTI_USER WITH NOWAIT
GO

--Report status on all databases
SELECT name,
CASE is_read_committed_snapshot_on
WHEN 1 THEN 'yes' ELSE 'no' END AS Read_Committed_Snapshot_Enabled
FROM sys.databases

No comments:

Post a Comment

Search Brian Hehir's sites

Loading