1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18:
ALTER PROCEDURE [dbo].[BusinessOrgReviewPeriodAccess_INS] ( @intBusinessOrgID int ) AS INSERT INTO dbo.BusinessOrgReviewPeriodAccess(BusinessOrg_ID, ReviewPeriod_ID, AppraisalsLocked) SELECT @intBusinessOrgID, ReviewPeriod_ID, 0 FROM dbo.ReviewPeriod WHERE StatusCode <> 'UPCM' -- Check if it didn't already existed AND NOT EXISTS ( SELECT 1 FROM dbo.BusinessOrgReviewPeriodAccess WHERE BusinessOrg_ID = @intBusinessOrgID AND ReviewPeriod_ID =ReviewPeriod_ID AND AppraisalsLocked=0 )