哦,这种情况是在你的那个字段本身就是那顺序排下来的情况下进行的。如果不是就比较麻烦了。可以这样 select identity(int,1,1)as upno,主键 into tab_temp from a update a set a001='DR'+right('00000'+cast(tab_temp.upno as integer),5) from tab_temp,a where a.主键=tab_temp.主键
to liuyun2003(流云) : 假如原来的数据有: 2300001,2400001,2500001. 那岂不是会出现重复数据了?A001是索引呢我是要把所有数据整理,从DR00001至DR99999递增的方式来更新它们
to liuyun2003(流云) : 你的方法应该可行,我试试,看看速度如何
select identity(int,1,1) as upno, B002 into tab_temp from B02 where B055 <> '999' update B02 set B02.B002 = 'DR'+right('00000'+cast(upno as varchar),5) from tab_temp,B02 where B02.B002=tab_temp.B002========> 服务器: 消息 512,级别 16,状态 1,过程 UPDATEX02,行 1 子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。 语句已终止。*********************************** 呵,怎么会出错呢?
select identity(int,1,1)as upno,主键 into tab_temp from a
update a set a001='DR'+right('00000'+cast(tab_temp.upno as integer),5) from tab_temp,a where a.主键=tab_temp.主键
假如原来的数据有: 2300001,2400001,2500001.
那岂不是会出现重复数据了?A001是索引呢我是要把所有数据整理,从DR00001至DR99999递增的方式来更新它们
你的方法应该可行,我试试,看看速度如何
update B02 set B02.B002 = 'DR'+right('00000'+cast(upno as varchar),5)
from tab_temp,B02 where B02.B002=tab_temp.B002========>
服务器: 消息 512,级别 16,状态 1,过程 UPDATEX02,行 1
子查询返回的值多于一个。当子查询跟随在 =、!=、<、<=、>、>= 之后,或子查询用作表达式时,这种情况是不允许的。
语句已终止。***********************************
呵,怎么会出错呢?