the error is here,insert begin and end condition
use the below solution
ALTER proc [dbo].[InsertUserIdMap]
@userid varchar(50),
@type varchar(50),
@typeid varchar(50),
@exists int=1 output
as
begin
declare @match varchar(500)
set @match =(select User_ID from UserIDMapping where User_ID =@userid and TypeId=@typeid)
if(@type='ADMIN')
begin
if exists (@match)
BEGIN
select @exists
END
else
BEGIN
insert into UserIDMapping (User_ID ,Table_Ref ,TypeId ) values (@userid ,'adminb2b' ,@typeid )
set @exists=0
END
end
end
it is good if u insert begin and end in every starting and closing condition