Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- --宣告計數變數
- DECLARE @NextID BIGINT
- --設定計數起始值
- SET @NextID = 0;
- With UpdateData As
- (
- SELECT SeqCounter,
- --設定CreateTime為排序欄位
- ROW_NUMBER() OVER(ORDER BY CreateTime) AS RN,CreateTime
- --設定更新資料表
- FROM BBBBB
- --設定更新欄位條件
- WHERE SeqIdentify='ASMM04P0' and CreateTime >= '2019-03-01 00:00:00.000'
- )
- --更新資料表,並將計數+1
- UPDATE BBBBB SET @NextID = SeqCounter = @NextID + 1
- FROM BBBBB
- INNER JOIN UpdateData ON BBBBB.CreateTime = UpdateData.CreateTime
- WHERE BBBBB.SeqIdentify='ASMM04P0' and BBBBB.CreateTime >= '2019-03-01 00:00:00.000'
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement