Arun Eddy

Arun Eddy

  • 1.3k
  • 402
  • 12k

need to limit data inserting

Apr 26 2018 6:10 AM
this is my procedure i want to limit the data inserting on give time like i want to insert only 12 member in a give time if the user is reach the number of value which i want to get is show the message else insert the value.
my procedure is doing the first part its tack the number of value which i want if the number of value is reach the number 12 than its show me the message but when i m change the time its also show me the same magess plz check what i m doing worng and if u have any solution about this plz provide me  
 
create procedure SP_insert_test
@name varchar(20),@emailid varchar(20),
@trainer_name varchar(50),@training_date varchar(50),@training_time varchar(50),@gymname varchar(50)
,@success int out
as
begin
if(select count(id) from Add_Booking_Fitness_Training where training_time=@training_time)>11
print N'Number of Booking Is Complete for this time and date plz book other time';
else
insert into Add_Booking_Fitness_Training(memeber_name,member_emailid,trainer_name,training_date,training_time,gymname)
values(@name,@emailid,@trainer_name,@training_date,@training_time,@gymname)
SELECT SCOPE_IDENTITY()
set @success=1;
end
begin
set @success=0;
end

Answers (4)