I need a sql query that updates new guid where it is null. But the update should happen based on another non-unique column.
For example, consider sample dbo.Products Table and it contains Product_Ref_Id and Product_Name.
Product_Ref_Id | Product_Name |
---|---|
NULL | Product1 |
NULL | Product1 |
NULL | Product1 |
NULL | Product2 |
NULL | Product2 |
NULL | Product2 |
In the above table, the Product_Ref_Id should be updated with same GUID for Product1 and another GUID applies to Product2 rows. So, the expected output is
Product_Ref_Id | Product_Name |
---|---|
28079cfa-2384-48c6-bf5b-488a31d33bdb | Product1 |
28079cfa-2384-48c6-bf5b-488a31d33bdb | Product1 |
28079cfa-2384-48c6-bf5b-488a31d33bdb | Product1 |
f40b7c2d-873e-48b6-b2c4-d01d2d7258bf | Product2 |
f40b7c2d-873e-48b6-b2c4-d01d2d7258bf | Product2 |
f40b7c2d-873e-48b6-b2c4-d01d2d7258bf | Product2 |
Appreciate your great help on this. Thanks.
3