update data append to another table data

Respondida update data append to another table data

  • Wednesday, July 25, 2012 1:33 PM
     
     

    hi all,

    this my structure

    tblAuther((Auther_ID,Auther_Name))

    tblArticle((Article_ID,Title,Auther_Name))

    the tblArticle Now Contain 30000 record I want Now replace The Auther_Name with Auther_ID.

    can any one help me?

All Replies

  • Thursday, July 26, 2012 5:48 AM
     
     Answered Has Code

    Hi,

    you can update your tblArticle using the script

    UPDATE A
    SET A.Auther_Name = B.Autherr_ID
    FROM tblAuther B
    JOIN tblArticle A
    ON A.Auther_Name = B.Auther_Name

    after that you can change the data type (if necessary) and change column name of Auther_name in tblArticle.

    * Note if there are two auther with the same name (and sure different ID) you need to review those authors for all other the update will do what you want.

    I hope this is helpful.


    Please Mark it as Answered if it answered your question
    OR mark it as Helpful if it help you to solve your problem
    Elmozamil Elamir Hamid

    MCTS: SQL Server Administration/Development

    MyBlog