Update with CASE statement

  • Tony Bater (2/22/2013)


    I answered the wrong question.:crying: "Objective: Update all the M's to F and all F's to M. " and the result of statement 4 will not be that objective. And as the question was phrased so confusingly I thought perhaps it meant did it succeed in meeting its objective. Clearly not, but then perhaps I ought to read questions more carefully!

    Yes, it did mean that and yes, statement 4 will succeed in doing that. If you don't believe that, try running it and see that it does.

    Tom

  • Oops again.:w00t:This time I didn't even read the objective correctly! for some reason I thought it was just to set all values of Gender to 'M'. Apologies to the question setter.


    Tony

  • Very good question. Also good way to show how values can be swapped. 🙂

  • Lokesh Vij (2/18/2013)


    For me the question was simple, clear and very basic. Thanks 🙂

    +1

    Jason...AKA CirqueDeSQLeil
    _______________________________________________
    I have given a name to my pain...MCM SQL Server, MVP
    SQL RNNR
    Posting Performance Based Questions - Gail Shaw[/url]
    Learn Extended Events

  • I, too caught on the (success OR failure), the collation-dependent field name, and the missed shorthand opportunity CASE Gender WHEN...

  • You can't answer a question of the type 'A or B? ' with TRUE or FALSE. Yet these are the only answers we can give.

    Clearly illogical.

  • Is it possible to insert values in only one column? Actually there are two columns in table they updating only one column what will happen to second

  • ramana3327 (4/19/2013)


    Is it possible to insert values in only one column? Actually there are two columns in table they updating only one column what will happen to second

    The other column was defined using the IDENTITY property. See http://msdn.microsoft.com/en-us/library/ms186775.aspx.


    Hugo Kornelis, SQL Server/Data Platform MVP (2006-2016)
    Visit my SQL Server blog: https://sqlserverfast.com/blog/
    SQL Server Execution Plan Reference: https://sqlserverfast.com/epr/

  • The question wordings were little confusing to me. But scored 1 mark.

    Thanks.

  • I don't get the clue. Is it so easy ?

Viewing 10 posts - 46 through 54 (of 54 total)

You must be logged in to reply to this topic. Login to reply