QOD 1/2/04

  • 1

    Edited by - sloanthrasher on 01/01/2004 8:36:17 PM


    Sloan

    If you can't do it in SQL, get a bigger hammer!

  • how is answer #2 different than #3 ???


    G.

  • quote:


    how is answer #2 different than #3 ???


    There's an extra () making the syntax invalid.

    Brian Knight

    bknight@sqlservercentral.com

    http://www.sqlservercentral.com/columnists/bknight

  • No there isn't, they're exactly the same

    Option 2:

    UPDATE FORUM_MEMBERS

    SET M_EMAIL = REPLACE(M_EMAIL,'@123.com', '@abc.com')

    WHERE M_EMAIL LIKE '%@abc.com'

    Option 3:

    UPDATE FORUM_MEMBERS

    SET M_EMAIL = REPLACE(M_EMAIL,'@abc.com', '@123.com')

    WHERE M_EMAIL LIKE '%@abc.com'

    Option 1 has the extra brackets...

  • The replace values are switched around.

    'abc.com','123.com'

    vs

    '123.com', 'abc.com'

  • Although I got the right answer, one does have to make a couple of significant assumptions to get there:

    1) The company uses the simplest form of its domain in all e-mail addresses (as opposed to jsmith@mail.abc.com, which is not incredibly uncommon).

    2) The named column is, indeed the one that holds the e-mail address.

    Not to mention that company 123 is unlikely to immediately discard the abc.com domain name, meaning that the best solution for the savvy database guru is that maybe a global replace isn't necessary - users should be notified of the need to update the e-mail addresses, and should update the addresses themselves.

    Of course, the savvy database guru also knows when to go ahead and do something because someone up the corporate ladder decides it has to be done and done now.

    R David Francis


    R David Francis

Viewing 6 posts - 1 through 5 (of 5 total)

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