     ON DELETE NO ACTION
     ON UPDATE NO ACTION
 );
-GO
 
 -- DASHBOARD RELATED VIEWS --
 
-CREATE VIEW POLICY_COMPLIANCE_INFO AS
+exec('CREATE VIEW POLICY_COMPLIANCE_INFO AS
 SELECT TOP 100 PERCENT
 DEVICE_INFO.DEVICE_ID,
 DEVICE_INFO.DEVICE_IDENTIFICATION,

FROM
DM_POLICY_COMPLIANCE_STATUS) DEVICE_WITH_POLICY_INFO
ON DEVICE_INFO.DEVICE_ID = DEVICE_WITH_POLICY_INFO.DEVICE_ID
ORDER BY DEVICE_INFO.DEVICE_ID;
GO

CREATE VIEW FEATURE_NON_COMPLIANCE_INFO AS
SELECT TOP 100 PERCENT
DM_DEVICE.ID AS DEVICE_ID,
DM_DEVICE.DEVICE_IDENTIFICATION,

DM_POLICY_COMPLIANCE_STATUS.DEVICE_ID = DM_DEVICE.ID AND
DM_DEVICE.DEVICE_TYPE_ID = DM_DEVICE_TYPE.ID AND
DM_DEVICE.ID = DM_DEVICE_DETAIL.DEVICE_ID
ORDER BY TENANT_ID, DEVICE_ID');

-- END OF DASHBOARD RELATED VIEWS --
