Skip to content

Commit 2525063

Browse files
authored
Create update-using-select-via-merge-sqlserver.sql
1 parent 2246011 commit 2525063

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed
Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
-- Method 3: Update via MERGE
2+
MERGE Course AS Target
3+
USING (
4+
SELECT id, code FROM Department
5+
) AS Source
6+
ON Target.department_id = Source.id
7+
WHEN MATCHED THEN
8+
UPDATE SET Target.is_active =
9+
CASE
10+
WHEN Source.code = 'ME' THEN 'Yes'
11+
ELSE 'No'
12+
END;

0 commit comments

Comments
 (0)