IF EXISTS (SELECT 1 FROM sys.objects WHERE object_id = OBJECT_ID('[dbo].[mps_new_role]') AND type = 'P')
DROP PROCEDURE [dbo].[mps_new_role]
GO
-- =============================================
-- Author:<Author,,Name>
-- Create date: <Create Date,,>
-- Description:<Description,,>
-- =============================================
CREATE procedure [dbo].[mps_new_role]
@cmpid int
AS 
BEGIN
-- SET NOCOUNT ON added to prevent extra result sets from
-- interfering with SELECT statements.
SET NOCOUNT ON;
SET TRANSACTION ISOLATION LEVEL READ UNCOMMITTED
declare @max_value int
select @max_value=max(rl_value)+1 from mps_role where rl_cmpid = @cmpid and rl_value<1000 
if @max_value is null
set @max_value=0
if (@max_value=0) set @max_value=1 


insert into mps_role(rl_cmpid,rl_system,rl_value,rl_title,rl_note) 
values(@cmpid,1,@max_value,'新建角色','')

select * from mps_role
where rl_value=@max_value and rl_cmpid = @cmpid  
END