SQL批量增加修改数据
1 insert into A表(字段1,字段2) select 字段1,字段2 From B表 2 [注:字段类型、字段数应相同] 3 4 --批量进行修改ID值 5 declare @i int 6 set @i=1 7 while @i<197 8 begin 9 update ComputerEquipmentListVIEW set ComputerID='000'+cast((4031+@i) as varchar(8)) From 10 (select IId=ROW_NUMBER()over(order by ID),* FROM ComputerEquipmentListVIEW) as d 11 where ComputerEquipmentListVIEW.ID=d.ID 12 and d.IId=@i 13 set @i=@i+1 14 end
好的代码就和美食一样,都是需要时间烹饪出来的!