About this question
How can you update a table in SQL Server using data from another table? What is the correct way to use UPDATE with a SELECT statement? Let’s explore the best methods to achieve this!
How can you update a table in SQL Server using data from another table? What is the correct way to use UPDATE with a SELECT statement? Let’s explore the best methods to achieve this!
Log in to share your answer and help other learners.
Log in to answerBest Answer · By JanBask MS SQL Server Expert
Answered on Apr 1, 2025
If you need to update a table in SQL Server using values from another table, you can do this efficiently using the UPDATE statement with a JOIN or a FROM clause. Here’s how you can do it!
1. Using UPDATE with JOIN (Recommended Approach)
This method is commonly used when updating a table with data from another table:
UPDATE t1
SET t1.column_name = t2.column_name
FROM Table1 t1
JOIN Table2 t2 ON t1.id = t2.id
WHERE t2.some_column = 'some_value';2. Using UPDATE with a Subquery
If you don’t need a join, you can update using a SELECT subquery:
UPDATE Table1
SET column_name = (SELECT column_name FROM Table2 WHERE Table2.id = Table1.id)
WHERE EXISTS (SELECT 1 FROM Table2 WHERE Table2.id = Table1.id);3. Using MERGE (For Complex Updates)
If you need to update or insert data based on conditions, use MERGE:
MERGE INTO Table1 AS t1
USING Table2 AS t2
ON t1.id = t2.id
WHEN MATCHED THEN
UPDATE SET t1.column_name = t2.column_name;Final Tips:
Free tutorials and interview questions from industry experts — learn the skill, then get ready to prove it.
Step-by-step SQL Server guides from industry experts
Common SQL Server interview questions, answered
Guides, tips and career advice on SQL Server from JanBask experts.
SQL Server Top 75 SSAS Interview Questions and Answers For Beginners & Experts
Prepare for your SSAS interview with our comprehensive guide featuring 75 top SQL Server Analysis Services interview questions…
SQL Server How to Become a SQL Database Administrator?
How to become a sql database administrator In 2025, discover what these professionals do, explore how much they earn and learn…
SQL Server OLAP vs OLTP: Key Differences, Architectures, Performance & Real-World Examples
Compare OLTP vs OLAP with clear definitions, architecture diagrams, real-world examples, and FAQs. Learn when to use each system…
SQL Server 70+ Most Asked SSIS Interview Questions for Freshers & Experienced
Prepare for your next SQL Server Integration Services (SSIS) interview with our top 70+ SSIS interview questions and answers.…