I have a table Product and I have a column in it called Genre which has null/unwanted values.
I want to update that column with a set of values:
Documentary
Comedy
Adventure/Action
Drama
Thriller
SF/Fantasy
Animation/Family
Others
The update can be in any order but I want every row in the column updated. How should I go about this?
Try something like this
UPDATE P
SET genre = rand_values
FROM Product p
CROSS apply (SELECT TOP 1 rand_values
FROM (VALUES ('Documentary'),
('Comedy'),
('Adventure/Action'),
('Drama'),
('Thriller'),
('SF/Fantasy'),
('Animation/Family'),
('Others')) tc (rand_values)
WHERE p.productid = p.productid -- This is just to correlate the query
ORDER BY Newid()) cs
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With