T SQL Development:Ensure Database Versions and Compatibility Levels for Latest Updates

preview_player
Показать описание
Join this channel to get access to perks:

Join the Telegram Group for the scripts and assistance:

You Can Also Download the scripts from below folder
We strongly believe there is always chance of betterment, so suggestions are most welcome.

Happy learning, and All the Best in your professional journey!

The journey of improvement is ongoing and never be an end.

#azuresql #azure #sqldba #sqlserverdba #sql #sqlserver #sqlserverdeveloper #performance #performancetuning #performanceoptimization #mssql #mssqlserver #mssqlserverdba

Thank you!
MS SQL DBA Tech Support
Рекомендации по теме
Комментарии
Автор

-- Create a temporary table
CREATE TABLE #TempDatabaseInfo (
ProductMajorVersion INT,
Name NVARCHAR(128),
CompatibilityLevel INT,
CompatibilityDescription NVARCHAR(50) -- New column for Compatibility Description
);

-- Insert data into the temporary table
INSERT INTO #TempDatabaseInfo
SELECT
CONVERT(INT, AS ProductMajorVersion,
name,
compatibility_level,
CASE
WHEN CONVERT(INT, = 11 AND compatibility_level = 110 THEN 'Having Latest version'
WHEN CONVERT(INT, = 12 AND compatibility_level = 120 THEN 'Having Latest version'
WHEN CONVERT(INT, = 13 AND compatibility_level = 130 THEN 'Having Latest version'
WHEN CONVERT(INT, = 14 AND compatibility_level = 140 THEN 'Having Latest version'
WHEN CONVERT(INT, = 15 AND compatibility_level = 150 THEN 'Having Latest version'
WHEN CONVERT(INT, = 16 AND compatibility_level = 160 THEN 'Having Latest version'
ELSE 'Please upgrade to ' + CAST(CONVERT(INT, * 10 AS NVARCHAR(5))
END AS CompatibilityDescription
FROM
sys.databases
WHERE
database_id > 4;

-- Query the temporary table
SELECT name, CompatibilityLevel, CompatibilityDescription FROM #TempDatabaseInfo;

-- Drop the temporary table when done
DROP TABLE #TempDatabaseInfo;

MSSQLDBATechSupport