1
我有一個包含部件列表的表。關鍵字(樣本中的「代碼」)只是一個分配的編號。不幸的是,這張表現在需要容納一些帶有預定義的代碼的新軟件。當然,這些定義的代碼與現有代碼相沖突。我想拿現有的鑰匙,並增加每個200,將他們移出碰撞空間。我想這個查詢:使用子查詢對錶中的鍵重新編號
update [TEST-PH].[dbo].[Emp_PosDepartments]
set Code = (select code + 200 from [TEST-PH].[dbo].[Emp_PosDepartments] o where o.Code = Code)
但是當我嘗試對SQL Server運行它,我得到以下信息:
Subquery returned more than 1 value. This is not permitted when the subquery follows =, !=, <, <= , >, >= or when the subquery is used as an expression.
任何建議如何完成重編鍵的任務嗎?