SET NOCOUNT ON
DECLARE @FK_DepartmentNumber INT
DECLARE @UserIdNumber INT
DECLARE @AreaFunctionNumber INT

DECLARE db_user CURSOR FOR
  SELECT UserIdNumber FROM Personel WITH (NOLOCK)
OPEN db_user

FETCH NEXT FROM db_user INTO @UserIdNumber

--Setting no access for handling signatures for Mærsk in Marketing
WHILE @@FETCH_STATUS = 0
BEGIN

  IF NOT EXISTS(SELECT * FROM PERSONELACCESS WITH (NOLOCK) 
  WHERE UserIdNumber = @UserIdNumber AND AreaNumber = 0 AND AreaFunctionNumber = 36)
    INSERT INTO PERSONELACCESS(UserIdNumber, AreaFunctionNumber, Access, AreaNumber) 
      VALUES (@UserIdNumber, 36, 2, 0)

  FETCH NEXT FROM db_user INTO @UserIdNumber
END  

CLOSE db_user
DEALLOCATE db_user