Select Case in Sql Server

Select Case in Sql Server

This is nothing but the switch case statement we use in our programing languages.which can be used with the case functions
under system function


Example:

 Declare @weekday int,@empNo int=1005
 
        Select @weekday=DatePart(dw,hiredate) from Employee where EmpNo=@EmpNo

        Select Case @weekday

        When 1 then 'Sunday'
 
        When 2 then 'Monday'

        When 3 then 'Tuesday'

        When 4 then 'Wedensday'

       When 5 then 'Thrusday'

       When 6 then 'Friday'

       else 'Saturday'

       End.


About Author: author 4 + years of Information Technology experience in understanding and analyzing the software and hardware engineering requirements, onsite and offshore management of product development. Expert work on design and development for windows,web,mobile Expert knowledge of C#,ADO.NET, ASP.Net MVC, ENTITY FRAMEWORK, LINQ,COLLECTIONS, JAVASCRIPT,AngularJs 1.0,Angular2, Jquery,Jquery-Ajax, SQL SERVER, XAML,Windows phone 8.1 Good knowledge of WCF-Restful services,WCF, WEB API-Services ,Web- Services,MIcrosoft-Azure,JUICE UI,HTML,CSS,AJAX Read More...

Join him on Google+ | Facebook | Linkedin

No comments