if Exists(select * from sysobjects where NAME = ‘insert_custominfo‘ and type=‘P‘)
drop procedure insert_custominfo
go
create proc insert_custominfo
@mid nvarchar(50),
@custominfoid nvarchar(50) output
as
begin
declare @num int
set @num =( select COUNT(*) from t_custominfo where c_id=@mid )
if(@num =0)
begin
insert into t_custominfo(c_id) values(@mid)
set @custominfoid = @@IDENTITY
end
else
begin
select @custominfoid=c_custominfoid from t_custominfo where c_id=@mid
end
end
declare @custominfoid int
exec insert_custominfo ‘1101‘,@custominfoid output
print @custominfoid