From the below table how to update the item column to null for all rows using merge update statement
| ID | Product | Items |
| 1 | Product1 | 2 |
| 2 | Product2 | 2 |
| 3 | Product3 | 2 |
| 4 | Product4 | 1 |
| 5 | Product5 | 1 |
Thanks
From the below table how to update the item column to null for all rows using merge update statement
| ID | Product | Items |
| 1 | Product1 | 2 |
| 2 | Product2 | 2 |
| 3 | Product3 | 2 |
| 4 | Product4 | 1 |
| 5 | Product5 | 1 |
Thanks
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Tahir AnsariRank #366 · 6.8K reputationPosted Sep 13, 2023, 2:18 PM EDT
MERGE INTO YourTable AS Target USING ( SELECT ID FROM YourTable ) AS Source ON (Target.ID = Source.ID) WHEN MATCHED THEN UPDATE SET Target.Items = NULL;Mohammad HussainRank #513 · 4.8K reputationPosted Sep 14, 2023, 2:57 AM EDT
MERGE INTO product AS Target USING (SELECT ID FROM product) AS Source ON Target.ID = Source.ID WHEN MATCHED THEN UPDATE SET Target.Items = NULL;Cr BhargaviRank #420 · 5.9K reputationPosted Sep 20, 2023, 7:01 AM EDT
MERGE INTO product AS Target USING (SELECT ID FROM product) AS Source ON Target.ID = Source.ID WHEN MATCHED THEN UPDATE SET Target.Items = NULL;Saravanan GanesanRank #153 · 15.1K reputationPosted Sep 24, 2023, 1:13 PM EDT
You can update the "Items" column to NULL for all rows in the table using a simple SQL UPDATE statement. There's no need to use a MERGE statement for this task. Here's the SQL statement to achieve this:
UPDATE YourTableName
SET Items = NULL;
Replace
YourTableNamewith the actual name of your table. This query will set the "Items" column to NULL for all rows in the table, effectively clearing the "Items" column for all records.