Created
October 18, 2013 00:20
-
-
Save pollusb/7034600 to your computer and use it in GitHub Desktop.
Just after migrating/upgrade databases to SQL Server
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
-- Change DB Owner, Compatibility Level and Page Verify | |
use master | |
go | |
declare @cmptlevel int | |
select @cmptlevel = compatibility_level from sys.databases where database_id = 1 | |
select 'ALTER DATABASE ['+name+'] SET COMPATIBILITY_LEVEL = ' + cast(@cmptlevel as varchar) + ';' | |
from sys.databases | |
where database_id > 4 and compatibility_level < @cmptlevel | |
select 'use ['+name+'];exec sp_changedbowner ''sa'';' | |
from sys.databases | |
where database_id > 4 and owner_sid <> 1 | |
select 'ALTER DATABASE ['+name+'] SET PAGE_VERIFY CHECKSUM;' | |
from sys.databases | |
where database_id > 4 and page_verify_option <> 2 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment