Advertisement
Guest User

Untitled

a guest
Mar 24th, 2019
57
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.59 KB | None | 0 0
  1. --宣告計數變數
  2. DECLARE @NextID BIGINT
  3. --設定計數起始值
  4. SET @NextID = 0;
  5. With UpdateData As
  6. (
  7. SELECT SeqCounter,
  8. --設定CreateTime為排序欄位
  9. ROW_NUMBER() OVER(ORDER BY CreateTime) AS RN,CreateTime
  10. --設定更新資料表
  11. FROM BBBBB
  12. --設定更新欄位條件
  13. WHERE SeqIdentify='ASMM04P0' and CreateTime >= '2019-03-01 00:00:00.000'
  14. )
  15. --更新資料表,並將計數+1
  16. UPDATE BBBBB SET @NextID = SeqCounter = @NextID + 1
  17. FROM BBBBB
  18. INNER JOIN UpdateData ON BBBBB.CreateTime = UpdateData.CreateTime
  19. WHERE BBBBB.SeqIdentify='ASMM04P0' and BBBBB.CreateTime >= '2019-03-01 00:00:00.000'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement