if exists(select 1 from sysobjects where name='pr_oper_grant')
  drop procedure pr_oper_grant
go

create procedure pr_oper_grant as
begin
	delete t_sys_oper_grant from t_cm_sys_oper_grant 
	where t_sys_oper_grant.oper_id = t_cm_sys_oper_grant.oper_id and
	 	t_sys_oper_grant.func_id = t_cm_sys_oper_grant.func_id
	if @@error !=0 goto ERR
	insert into t_sys_oper_grant select * from t_cm_sys_oper_grant
	truncate table t_cm_sys_oper_grant
	if @@error !=0 
		goto ERR
	else
		return
	err:
		rollback;
		return 
end
go
