我有在MS SQL服務器(TSQL)更新的問題
假設我有一個表人與描述和ID字段和插入1000條記錄此表與此值更新許多records.should我使用光標?
1 Descript1
2 Descript2
3 Descript3
.. ......
.. ......
1000 Descript1000
我怎樣才能改變這個1000條記錄下同記錄
1 Description1
2 Description2
3 Description3
......
......
1000 Description1000
我應該使用光標? 我寫此查詢,但它不工作
while @Counter<=1000000
begin
update Person set Description='Descripton'+CONVERT(nvarchar(15),@Counter) where ID>=1
set @[email protected]+1
end
運行在基於集時尚查詢是_much_比逐行更快(如while循環,遊標等)。 – Bridge