sqlserverでのテンポラリテーブル、row-number、update更新自体
2152 ワード
SELECT * INTO #TempStudent FROM
(SELECT id, ROW_NUMBER() OVER(ORDER BY id) RowNum FROM dbo.student) NewT
UPDATE dbo.student SET score=#TempStudent.RowNum
FROM dbo.student stu LEFT JOIN #TempStudent
ON stu.id=#TempStudent.id
UPDATE dbo.PMS_Commodity SET C_ModifyTime=GETDATE()
FROM dbo.PMS_Commodity pc LEFT JOIN
dbo.PMS_CommodityProduct cp ON pc.C_ID=cp.C_CommodityID
LEFT JOIN dbo.PMS_Product pp ON pp.C_ID=cp.C_ProductID
WHERE C_ProductID='2F06EF2E-DEBB-494A-82AC-0022B3BE8608'