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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. Database & SysAdmin
  3. Database
  4. I want your idear and solving !!!

I want your idear and solving !!!

Scheduled Pinned Locked Moved Database
databasequestioncsharpsql-server
3 Posts 2 Posters 1 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.
  • G Offline
    G Offline
    Golden Jing
    wrote on last edited by
    #1

    Suppose I have a table tblEmpStop EmpID Date Reason -------------------------------------------- 1 01/01/2009 Fi 2 03/01/2009 Rs 3 03/01/2009 TS I want to make a view/query which take from tblEmpStop n replace in Coluem Reason EmpID Date Reason -------------------------------------------- 1 01/01/2009 Fired 2 03/01/2009 Resigned 3 03/01/2009 Temporary Stop I use Ms SQL Server 2000 with source code: SELECT EmpID, [Date], IF Reason = Fi, Fire; elseif Reason = Rt, Retired; elseif Reason = Rs, Resigned AS ReasonStop FROM dbo.tblEmpStop but it did not work... How can i do what i want above ? Thanks you before hand Best regard, Sovann

    VB.Net

    W 1 Reply Last reply
    0
    • G Golden Jing

      Suppose I have a table tblEmpStop EmpID Date Reason -------------------------------------------- 1 01/01/2009 Fi 2 03/01/2009 Rs 3 03/01/2009 TS I want to make a view/query which take from tblEmpStop n replace in Coluem Reason EmpID Date Reason -------------------------------------------- 1 01/01/2009 Fired 2 03/01/2009 Resigned 3 03/01/2009 Temporary Stop I use Ms SQL Server 2000 with source code: SELECT EmpID, [Date], IF Reason = Fi, Fire; elseif Reason = Rt, Retired; elseif Reason = Rs, Resigned AS ReasonStop FROM dbo.tblEmpStop but it did not work... How can i do what i want above ? Thanks you before hand Best regard, Sovann

      VB.Net

      W Offline
      W Offline
      Wendelius
      wrote on last edited by
      #2

      Its easiest to use CASE[^]. So your query would be like:

      SELECT EmpID,
      [Date],
      CASE Reason
      WHEN 'Fi' THEN 'Fire'
      WHEN 'Rt' THEN 'Retired'
      ...
      END AS Reason
      FROM dbo.tblEmpStop

      The need to optimize rises from a bad design.My articles[^]

      G 1 Reply Last reply
      0
      • W Wendelius

        Its easiest to use CASE[^]. So your query would be like:

        SELECT EmpID,
        [Date],
        CASE Reason
        WHEN 'Fi' THEN 'Fire'
        WHEN 'Rt' THEN 'Retired'
        ...
        END AS Reason
        FROM dbo.tblEmpStop

        The need to optimize rises from a bad design.My articles[^]

        G Offline
        G Offline
        Golden Jing
        wrote on last edited by
        #3

        Thanks your for your help. But when i run it show message like: The Query Designer does not support the CASE SQL construct. But it was work... :-) Thanks you again..

        VB.Net

        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