日期:2014-05-18  浏览次数:20472 次

高手请帮忙
test                 test2                                         test3
301113367   飞虹路600弄9号2501室 117501
301113367   飞虹路600弄9号2302室 117500
301113367   飞虹路600弄9号2301室 117499
301113367   飞虹路600弄9号2202室 117498
301113367   飞虹路600弄9号2201室 117497
301113367   飞虹路600弄9号2102室 117496
301113367   飞虹路600弄9号2101室 117495
301113367   飞虹路600弄9号2002室 117494
301113367   飞虹路600弄9号2001室 117493
301113367   飞虹路600弄9号1902室 117492
301113367   飞虹路600弄9号1901室 117491
301113367   飞虹路600弄9号1802室 117490
301113367   飞虹路600弄9号1801室 117489
301113367   飞虹路600弄9号1702室 117488
301113367   飞虹路600弄9号1701室 117487
301113367   飞虹路600弄9号1602室 117486
301113367   飞虹路600弄9号1601室 117485
301113367   飞虹路600弄9号1502室 117484
301113367   飞虹路600弄9号1501室 117483
301113367   飞虹路600弄9号1302室 117482
301113367   飞虹路600弄9号1301室 117481
301113367   飞虹路600弄9号1202室 117480
301113367   飞虹路600弄9号1201室 117479
301113367   飞虹路600弄9号1102室 117478
301113367   飞虹路600弄9号1101室 117477
301113367   飞虹路600弄9号1002室 117476
如何用SQL更新test字段的值。  
我想test的值递增

------解决方案--------------------
存储过程写循环修改表
------解决方案--------------------
test建表时成递增的
------解决方案--------------------
设置该字段为int
在标识规范属性中设置为自增量,种子为1
------解决方案--------------------
declare @i int
set @i=301113367
declare a_ta_t cursor scroll for
select test from tablename
for update of test
declare @fetch_status int
open a_ta_t
fetch a_ta_t
select @fetch_status = @@Fetch_status
while @fetch_status =0
begin
@i=@i+1
update tablename
set test=@i
where current of a_ta_t
fetch a_ta_t
select @fetch_status = @@Fetch_status
end
close a_ta_t
deallocate a_ta_t
go
------解决方案--------------------
把列清空,再自增。