USE [MBAM Compliance Status]
GO
/****** Object: StoredProcedure [ComplianceCore].[UpdateCache] ******/
SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [ComplianceCore].[UpdateCache]
WITH EXECUTE AS OWNER
AS
BEGIN
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
DECLARE @OrigTranCount int
SET @OrigTranCount = @@TRANCOUNT
IF @OrigTranCount > 0
SAVE TRAN myTran
ELSE
BEGIN TRAN
BEGIN TRY
DELETE
FROM ComplianceCore.MachineCompliance
DBCC CHECKIDENT('ComplianceCore.MachineCompliance', RESEED, 0)
INSERT INTO ComplianceCore.MachineCompliance (LatestEntry, Name,
DomainName, ErrorInfoName, ExemptionStatusId, IsCompliant, MachinesUsersNames)
SELECT ComplianceCore.MachinesComplianceView.LatestEntry,
ComplianceCore.MachinesComplianceView.Name,
ComplianceCore.MachinesComplianceView.DomainName,
ComplianceCore.MachinesComplianceView.ErrorInfoName,
ComplianceCore.MachinesComplianceView.ExemptionStatusId,
ComplianceCore.MachinesComplianceView.IsCompliant,
N''
FROM ComplianceCore.MachinesComplianceView
IF @OrigTranCount = 0
COMMIT TRAN
END TRY
BEGIN CATCH
IF @OrigTranCount = 0
ROLLBACK TRAN
ELSE
IF XACT_STATE() <> -1
ROLLBACK TRAN myTran
DECLARE @ErrorMessage1 NVARCHAR(4000);
DECLARE @ErrorSeverity1 INT;
DECLARE @ErrorState1 INT;
SELECT @ErrorMessage1 = ERROR_MESSAGE();
SELECT @ErrorSeverity1 = ERROR_SEVERITY();
SELECT @ErrorState1 = ERROR_STATE();
RAISERROR (@ErrorMessage1, -- Message text.
@ErrorSeverity1, -- Severity.
@ErrorState1 -- State.
);
END CATCH
END