Update table

Posted on 2009-12-21
Last Modified: 2012-05-08
I need to update a table called "MyTable", this table has several columns but one of the columns may contain blanks sometime and i want to populate the blanks with onother column's data.  Here is how it look like my table:

ID                  NAME           TP_NAME            LOCATION
20                 ABC                LLM12                   NC
40                 MOX                XX14                     WA
25                 MMX                                              AZ
88                 XXX                                               OH
45                 LLP                 MO56                      KS

So in this case, since TP_NAME for ID 25 is blank i would like to update it with the same data as the NAME (MMX).  After the update, my table should look like this:
20                 ABC                LLM12                   NC
40                 MOX                XX14                     WA
25                 MMX                MMX                       AZ
88                 XXX                 XXX                       OH
45                 LLP                 MO56                      KS
Question by:karinos57
    LVL 75

    Accepted Solution

    update MyTable
    set TP_NAME    = Name
    where tp_name is NULL or TP_Name  = ''
    LVL 7

    Assisted Solution

    This will do..

    TP_NAME    = NAME
    TP_NAME IS NULL or TP_NAME  = ''

    Author Closing Comment


    Featured Post

    IT, Stop Being Called Into Every Meeting

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Join & Write a Comment

    A recent questions about how to add SSRS named instances, couldn't find any that talks about SQL server 2008, anyway I decided to help by creating some screen shots. The installation is straightforward, you just pop the SQL server 2008 installatiā€¦
    It is helpful to note: This is a cosmetic update and is not required, but should help your reports look better for your boss.  This issue has manifested itself in SSRS version 3.0 is where I have seen this behavior in.  And this behavior is only seeā€¦
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.

    729 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    22 Experts available now in Live!

    Get 1:1 Help Now