新聞中心
這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
教您如何使用SQL語句逐條更新每條記錄
如果我們需要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外連接簡介
當(dāng)前題目:教您如何使用SQL語句逐條更新每條記錄
文章出自:http://fisionsoft.com.cn/article/dhejsis.html


咨詢
建站咨詢
