sql server如何批量更新資料

時間 2021-10-14 22:23:54

1樓:匿名使用者

update 表名 set value=case when id=1 then 一個值

when id=2 then 一個值

when id=3 then 一個值 else valueend上邊就是舉個例子,意思是,當id=1時,把value設定個值,當id=2時,value設定另一個值,依次類推,不需要更改的保留原來的value值,最後以end結尾

2樓:糖糖寳寳

declare @cnt int

select @cnt = count(1) from awhile(@cnt > 0)

begin

--更新

set @cnt = @cnt - 1

end做個臨時表放置標識欄位跟狀態,對滿足某個狀態的批量update。

索引可以優化查詢,update跟delete這種操作反而會破壞索引。

3樓:匿名使用者

把這張表;也匯入sql;再用來更新

update 要根據的表 set 更新的欄位 from 要更新的表 a left 匯入sql的表 as b

on a.id =b.id

4樓:匿名使用者

可以根據你的需求寫一個儲存過程或者觸發器,把你的更新內容value寫在一個串或者什麼裡面儲存,每次就改這個位置

5樓:文走

用excel輔助,請參考

如有疑問,請追問。

sql 批量更新資料

6樓:匿名使用者

給你寫個sqlserver的,其他資料庫的話另說

1update table2 set pwd=table1.ip from table1 inner join table2 on table1.username=table2.

username

7樓:匿名使用者

update a set a.type=b.type from b where a.id=b.id

為什麼要一次更新1000條那,如果你硬是想要那樣更新那就在加上個條件如下

update a set a.type=b.type from b where a.id=b.id

and a.id in(select top 1000 a.id from a,b where a.id=b.id and a.type!=b.type)

8樓:匿名使用者

update t1 set type=t2.type from b t1

inner join a t2 on t1.type=t2.id

9樓:匿名使用者

update b set type = (select type from a where a.id=b.id ) where rownum < 1001

sqlserver更新語句

update table 1 set code 333 where exists select top 2 id,name from table 2 where table 1.id id and table 1.name name order by id 不知道你的top的用意,如果確實只提取子查...

帝國cms怎麼隨機批量更新資訊釋出的日期

青木堂 用sql語句啊,帝國後臺有一個執行sql的功能 帝國cms怎麼批量新增資訊的tags monster方 修改步驟 1 以下 加入到admin ecmsinfo.php,在任意2個elseif中間插入就行 elseif enews addtags all 列表批量新增tags 2 將以下 加入...

網頁文字如何批量替換,網頁文字如何批量替換?

創e生活 可以做一個 都是文字域,先獲取所有文字域裡面的文字,然後根據你輸入的字替換,替換後再賦值回去,這個元件還是需要花些時間的 替換文字,即,在畫面沒有完全載入,或者不能顯示時,其中圖象在畫面不能顯示將被顯示在文字 的位置,將有一個紅色交叉,屆時將有一個紅色的十字旁 標題,這是一個影象替換文字 ...