当前位置: 代码迷 >> Sql Server >> 怎样用sql语句把一个数字字段的值从小到大update了。(就像自动编号那样,从1开始)解决方法
  详细解决方案

怎样用sql语句把一个数字字段的值从小到大update了。(就像自动编号那样,从1开始)解决方法

热度:54   发布时间:2016-04-27 16:40:40.0
怎样用sql语句把一个数字字段的值从小到大update了。(就像自动编号那样,从1开始)
很急,谢谢

------解决方案--------------------
select identity(int,1,1) as sn,field1 into #t from t1;
update #t set field1=sn;
------解决方案--------------------

create table #t(id int, ff varchar(10))

insert into #t(ff) select 'a '
insert into #t(ff) select 'b '
insert into #t(ff) select 'c '


declare @i int
set @i=0

update #t set [email protected],@[email protected]+1

select * from #t


drop table #t
------解决方案--------------------
# 临时表
## 全局临时表
  相关解决方案