update table set no=to_char(rownum+100)
解决方案 »
- 求一记录语句
- SQLserver2000 如何执行.sql的脚本
- 关于SQL Server服务器硬件配置的问题,现在有一个SQL Server用的服务器,并发用户>50(一直维持这么多的并发用户,并发连接大约维持在200
- 同时插入和查询
- 求教 pengdali(大力 V3.0) 等高手
- 马上需要答复(急...急...急)
- sql server7.0 怎样定义一全局变量
- General Sql error
- 高分求解Output參數的一個簡單疑問!!
- sqlce 與SQLSERVER同步
- 关于SQL SERVER 的问题(急,急,急)!
- SQL Server中的怎样进行宏替换,类似VFP中的&或()
原来的NO值是不规则的字符串。我用的是ms sql server 7
我已经试过肯定可以
rownum是指什么?
ms sql server 7好像不支持
create table #table_temp(RowNo int IDENTITY(100,1),NO char(3))
insert into #table_temp (NO)
select NO from Table1update Table1
set Table1.NO=convert(char(3),RowNo)
from Table1,#table_temp
where Table1.NO=#table_temp.NO
select NO
from Table1update Table1
set Table1.NO=convert(char(3),RowNo)
from Table1,#table_temp
where Table1.NO=#table_temp.NO
select no,name,age from YourTableName
declare @NoVal INT
set @NoVal=100
open UpdateNoCursor
fetch next from UpdateNoCursor
while @@fetch_status=0
begin
update YourTableName set no=@NoVal
fetch next from UpdateNoCursor
set @NoVal=@NoVal+1
end
close UpdateNoCursor
deallocate UpdateNoCursor
select no,name,age from YourTableName
declare @NoVal INT
set @NoVal=100
open UpdateNoCursor
fetch next from UpdateNoCursor
while @@fetch_status=0
begin
update YourTableName set no=convert(char(3),@NoVal)
fetch next from UpdateNoCursor
set @NoVal=@NoVal+1
end
close UpdateNoCursor
deallocate UpdateNoCursor