Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
SQL Server knows your future compatiblity level... danger!
--Do you really reallly want to run this?
DECLARE @highestcompatlevel TINYINT,
@dbname NVARCHAR(128),
@sql NVARCHAR(400);
SELECT @highestcompatlevel = MAX(compatibility_level)
FROM sys.databases;
SELECT @dbname = DB_NAME();
SELECT @sql = 'ALTER DATABASE [' + @dbname + '] set compatibility_level = ' + CAST(@highestcompatlevel AS NVARCHAR(3));
PRINT @sql;
--Do you really reallly want to run this?
--EXECUTE sp_executesql @sql
@nanoDBA

This comment has been minimized.

Copy link
Owner Author

nanoDBA commented Jan 10, 2018

Okay - max isn't really the future.
But it could be the future of your current database.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.