if (not exists (select N from PermissionTypes where N=7418)) then insert into PermissionTypes (N,Name,"Default") values (7418,'Разпределение консумативи',1) end if go if (not exists (select TagNo from PermissionTags where TagNo=7418 and "Type"=7418)) then insert into PermissionTags (TagNo,"Type",Note) values (7418,7418,'Разпределение на консумативи') end if go for f as curs scroll cursor for select N as @AdminGroupN from AdminGroups do if (not exists (select GroupNo from Permissions where GroupNo=@AdminGroupN and PermissionNo=7418)) then insert into Permissions(GroupNo,PermissionNo,Stoinost) values (@AdminGroupN,7418,if @AdminGroupN=1 then 0 else 1 endif) end if end for go