Update Table Query to update data from another table directly

Posted by Lakhangarg under Sql Server category on | Views : 2338
Suppose we have two tables names:
Tbl_Topics & Tbl_TeacherTopics having columns
MyTopic, TopicId, TopicName
TeacherTopicID, TopicId, TopicName
And we want to update Tbl_Topics Table from Tbl_TeacherTopics for given TeacherTopicID


UPDATE Tbl_Topics SET TopicID=TT.TopicID,TopicName=TT.TopicName FROM
(SELECT TopicID,TopicName FROM Tbl_TeacherTopics WHERE TeacherTopicID=1062)AS TT
WHERE Tbl_Topics.MyTopic='Lakhan Pal garg'

Comments or Responses

Login to post response