This is the sample code snippets will give uses of datediff and >= in stored procedure.
declare @jobid varchar(50) declare @empid varchar(50) declare @diffyear varchar(50) set @jobid='0' set @empid='0'
select @jobid=job_id from emp_profile where job_id=@job_id select @empid=@emp_email_id from emp_profile where emp_email_id=@emp_email_id
select @diffyear= datediff(yy,@dob,@date_of_joining)
if @empid='0' and @jobid='0' and @diffyear>=22 begin
insert into emp_profile(job_id,emp_name,emp_desig,emp_contact_no,emp_email_id,date_of_joining, marital_status,dob,sex,emp_address,city,state,country,zip_code)
values(@job_id,@emp_name,@emp_desig,@emp_contact_no,@emp_email_id,@date_of_joining, @marital_status,@dob,@sex,@emp_address,@city,@state,@country,@zip_code)
return 11 end else if @empid='0' and @jobid<>'0' begin return 22 end else if @empid<>'0' and @jobid='0'
begin return 33 end else if @empid<>'0' and @jobid<>'0'
begin return 44 end else if @diffyear<22 begin return 55 end
|
No responses found. Be the first to respond and make money from revenue sharing program.
|