我嘗試以下操作:更新SQL Server表與隨機名稱
update [Employees] set Last_User =
(select top 1 name from
(select 'John' as name
union select 'Tim' as name
union select 'Jane' as name
union select 'Jack' as name
union select 'Steve' as name
union select 'Ann' as name
)
as names order by newid())
但保留所有行得到相同的名稱。我怎樣才能讓它變化?
注意:名稱是在查詢中輸入的,而不是來自其他表格。
感謝
你做'update Employees ='隨機選取的名字'這意味着所有的員工都會得到那個隨機的名字。 – Andrew
可能重複的[如何用另一個表中的隨機行更新表的每一行](http://stackoverflow.com/questions/29760225/how-to-update-each-row-of-a-table-與隨機行從另一個表) – Andrew