uodate语句
create table test
(
pk_id varchar(20)
)
insert into test select '290 '
insert into test select '290 '
insert into test select '290 '
insert into test select '290 '
insert into test select '290 '
insert into test select '290 '
--Update A Set pk_id = (Select Count(*) From test Where pk_id <= A.pk_id) From test A
select * from test
/*
写一句update语句,把pk_id列更新为 '1 ', '2 ', '3 '.....依次递增
name
1
2
3
4
5
6
*/
drop table test
[解决办法]
create table test
(
pk_id varchar(20)
)
insert into test select '290 '
insert into test select '290 '
insert into test select '290 '
insert into test select '290 '
insert into test select '290 '
insert into test select '290 '
Declare @I Int
Select @I = 0
Update test Set pk_id = @I , @I = @I + 1
select * from test
[解决办法]
declare @ID int
SET @id = 0
UPDATE test SET
@id = @id + 1,
pk_id = @id
select * from test