On Microsoft SQL Server 2008, I have a table with Products:
Id | Name | DefaultImageId
And one with Images:
Id | ProductId |
Another possible solution
UPDATE Products SET DefaultImageId = ( SELECT TOP 1 Id FROM Images ORDER BY NEWID(), Products.Id )