Tag: Choose

  • Logical function – Choose – SQL Server 2012

    CHOOSE function is the logical function. It is similar to SWITCH function in .NET. Choose function will return the item at the specified index from the list of values .

    -- below query will return "SQLDBPool-2"as output
    Select CHOOSE(2,'SQLDBPool','SQLDBPool-2','SQLDBPool-3')
    
    -- below query will return "Thursday"as output
    DECLARE @day as int
    set @day = 5
    SELECT Choose(@day,'Sunday','Monday', 'Tuesday', 'Wednesday','Thursday','Friday','Saturday')