sqlserver中临时表、row-number、update更新自己

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'

 

你可能感兴趣的:(sqlserver)