Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Database & SysAdmin
  3. Database
  4. Switch Case stmt!

Switch Case stmt!

Scheduled Pinned Locked Moved Database
help
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • L Offline
    L Offline
    Learner520
    wrote on last edited by
    #1

    Hi everOne I have used switch case statment before but not sure the way I want to use it is implementable or not. If it is then please could you convert the following code into switch Case statement. create proc Details_GetBYID ( @Id int, @TypeId nvarchar(max) ) AS IF @TypeId = 'P1' BEGIN SELECT motot.Completed,motot.Hours,motot.Subject FROM MasterT as motot INNER JOIN PSALevel as psal on psal.Id = motot.Id WHERE motot.Id = @Id END ELSE IF @TypeId = 'P2' BEGIN SELECT motot.Completed,motot.Hours,motot.Subject FROM MasterT as motot INNER JOIN PSALevel as psal on psal.Id = motot.Id WHERE motot.Id = @Id END ELSE BEGIN SELECT motot.Completed,motot.Hours,motot.Subject FROM MasterT as motot INNER JOIN PSALevel as psal on psal.Id = motot.Id WHERE motot.Id = @Id END any help would be appriciated. thanks in adv. regards learner

    I M 2 Replies Last reply
    0
    • L Learner520

      Hi everOne I have used switch case statment before but not sure the way I want to use it is implementable or not. If it is then please could you convert the following code into switch Case statement. create proc Details_GetBYID ( @Id int, @TypeId nvarchar(max) ) AS IF @TypeId = 'P1' BEGIN SELECT motot.Completed,motot.Hours,motot.Subject FROM MasterT as motot INNER JOIN PSALevel as psal on psal.Id = motot.Id WHERE motot.Id = @Id END ELSE IF @TypeId = 'P2' BEGIN SELECT motot.Completed,motot.Hours,motot.Subject FROM MasterT as motot INNER JOIN PSALevel as psal on psal.Id = motot.Id WHERE motot.Id = @Id END ELSE BEGIN SELECT motot.Completed,motot.Hours,motot.Subject FROM MasterT as motot INNER JOIN PSALevel as psal on psal.Id = motot.Id WHERE motot.Id = @Id END any help would be appriciated. thanks in adv. regards learner

      I Offline
      I Offline
      i j russell
      wrote on last edited by
      #2

      Try this[^]

      1 Reply Last reply
      0
      • L Learner520

        Hi everOne I have used switch case statment before but not sure the way I want to use it is implementable or not. If it is then please could you convert the following code into switch Case statement. create proc Details_GetBYID ( @Id int, @TypeId nvarchar(max) ) AS IF @TypeId = 'P1' BEGIN SELECT motot.Completed,motot.Hours,motot.Subject FROM MasterT as motot INNER JOIN PSALevel as psal on psal.Id = motot.Id WHERE motot.Id = @Id END ELSE IF @TypeId = 'P2' BEGIN SELECT motot.Completed,motot.Hours,motot.Subject FROM MasterT as motot INNER JOIN PSALevel as psal on psal.Id = motot.Id WHERE motot.Id = @Id END ELSE BEGIN SELECT motot.Completed,motot.Hours,motot.Subject FROM MasterT as motot INNER JOIN PSALevel as psal on psal.Id = motot.Id WHERE motot.Id = @Id END any help would be appriciated. thanks in adv. regards learner

        M Offline
        M Offline
        Mschauder
        wrote on last edited by
        #3

        Hey, why did you use "ELSE IF" when "ELSE" is same??? thats like

        if a = 1 then
        "abc"
        else if a = 2 then
        "222"
        else
        "222"

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups