掃二維碼與項(xiàng)目經(jīng)理溝通
我們?cè)谖⑿派?4小時(shí)期待你的聲音
解答本文疑問/技術(shù)咨詢/運(yùn)營(yíng)咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流
如果我們需要SQL語句逐條更新每一條記錄的值,應(yīng)該如何操作呢?下面就將為您介紹SQL語句逐條更新的方法,供您參考

- -------------------------以下為逐條更新語句
- declare @i int
- declare @j int
- declare @ID int
- set @j=1
- select @i=count(*) from t_CaiWuTable05
- DECLARE t_CaiWuTable05_cursor CURSOR FOR SELECT AutoId FROM t_CaiWuTable05
- OPEN t_CaiWuTable05_cursor
- while @j<=@i
- begin
- FETCH NEXT FROM t_CaiWuTable05_cursor into @ID
- update t_CaiWuTable05 set ZJBL=rtrim('ZJBL'+cast(@j as char)) where AutoId=@ID
- set @j=@j+1
- end
- CLOSE t_CaiWuTable05_cursor
- DEALLOCATE t_CaiWuTable05_cursor
【編輯推薦】
SQL整體更新的方法
SQL條件語句實(shí)例
鎖定SQL表的語句
SQL內(nèi)連接詳解
SQL外連接簡(jiǎn)介

我們?cè)谖⑿派?4小時(shí)期待你的聲音
解答本文疑問/技術(shù)咨詢/運(yùn)營(yíng)咨詢/技術(shù)建議/互聯(lián)網(wǎng)交流