Block Database Conversion Trigger


ALTER TRIGGER [dbo].[OM_Block_DB_Conversion_900]
   ON [dbo].[$ndo$dbproperty]
   AFTER UPDATE
AS
BEGIN
  SET NOCOUNT ON;

  DECLARE @OtherDatabaseVersionNo INTEGER = 0;
  DECLARE @Message NVARCHAR(100);

  SELECT @OtherDatabaseVersionNo = 1
  FROM Inserted i
    INNER JOIN Deleted d
      ON i.programid = d.programid
  WHERE i.databaseversionno <> d.databaseversionno;
  IF @OtherDatabaseVersionNo = 1
  BEGIN
    SET @Message =
      CHAR(13) + CHAR(10) + CHAR(13) + CHAR(10) +
      'OBJECT MANAGER ERROR:' + CHAR(13) + CHAR(10) +
      'Database cannot be converted.' + CHAR(13) + CHAR(10) +
      'Please first remove the Block Database Conversion trigger.' + CHAR(13) + CHAR(10);

    RAISERROR(@Message, 16, 1);
    ROLLBACK TRANSACTION;
  END;

END