dotnetspider.com
Login Login    Register      

TutorialsForumCareer DevelopmentResourcesReviewsJobsInterviewCommunitiesProjectsTraining

Subscribe to Subscribers
Talk to Webmaster
Tony John

Facebook
Google+
Twitter
LinkedIn
Online MembersPrasad kulkarni
More...
Join our online Google+ community for Bloggers, Content Writers and Webmasters




Resources » Code Snippets » C# Syntax

Uses of datediff and >= in stored procedure


Posted Date:     Category: C# Syntax    
Author: Member Level: Silver    Points: 10



 


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





Did you like this resource? Share it with your friends and show your love!


Responses to "Uses of datediff and >= in stored procedure"

No responses found. Be the first to respond...

Feedbacks      

Post Comment:




  • Do not include your name, "with regards" etc in the comment. Write detailed comment, relevant to the topic.
  • No HTML formatting and links to other web sites are allowed.
  • This is a strictly moderated site. Absolutely no spam allowed.
  • Name:   Sign In to fill automatically.
    Email: (Will not be published, but required to validate comment)



    Type the numbers and letters shown on the left.


    Next Resource: Two buttons on home page
    Previous Resource: Graph in Crystal Report
    Return to Resources
    Post New Resource
    Category: C# Syntax


    Post resources and earn money!
     
    More Resources
    Popular Tags   Tag posting guidelines   Search Tags  
    Datediff  .  



    Follow us on Twitter: https://twitter.com/dotnetspider

    Active Members
    TodayLast 7 Daysmore...

    Awards & Gifts
    Email subscription
  • .NET Jobs
  • .NET Articles
  • .NET Forums
  • Articles Rss Feeds
    Forum Rss Feeds


    About Us    Contact Us    Copyright    Privacy Policy    Terms Of Use    Revenue Sharing sites   Advertise   Talk to Tony John
    Copyright © SpiderWorks Technologies Pvt Ltd., Kochi, India
    2005 - 2012 All Rights Reserved.
    .NET and other trademarks mentioned in this site belong to Microsoft and other respective trademark owners.
    Articles, tutorials and all other content offered here is for educational purpose only.
    We are not associated with Microsoft or its partners.