Created
January 10, 2018 18:07
-
-
Save nanoDBA/dfe29e7635a20b7c56bafacd6ad09bad to your computer and use it in GitHub Desktop.
SQL Server knows your future compatiblity level... danger!
This file contains 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
--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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Okay - max isn't really the future.
But it could be the future of your current database.