CREATE PROCEDURE dbo.GDPRModeIsSet @AContainment BIT OUTPUT, @ADefault BIT = 1 AS
/*
  Created By Kent Johansen November 2017
  Returns true if db and server is ready for GDPR
*/

DECLARE @ver VARCHAR(MAX)
SELECT @ver = CAST(SERVERPROPERTY('productversion') AS VARCHAR(100))
IF CAST(SUBSTRING(@ver, 0, CHARINDEX('.', @ver)) AS INT) >= 13 -- SQL Server 2016 or newer
BEGIN
  DECLARE @DbName VARCHAR(1000)
  SELECT @DbName = DB_NAME()
  SELECT @AContainment = CAST(CAST(DATABASEPROPERTYEX(@DbName, 'containment') AS INT) AS BIT)
END
ELSE
  SET @AContainment = @ADefault