在网站找一段,发现并没有达到自己的要求:
这段程序功能是 为某空字段自动编号(系统运用时,新加的编号字段,前期有数据,需要重新编号)
declare @id int
declare @maxid int
set @id=1
select @maxid=count(*) from t_Send_Revisit Where fSO is null
begin
while @id<[email protected]
begin
update s set fSO =(Select ‘SR‘ +CONVERT(varchar(100), GETDATE(), 112)+ ‘-‘ +RIGHT(‘0000‘+convert(varchar,@id),4)) from t_Send_Revisit s
inner join (select top 1 * From t_Send_Revisit Where fSO is null ) t on t.SSO=s.SSO and t.STime = s.STime and t.fSNo= s.fSNo and s.CustCode = t.CustCode
set @[email protected]+1
end
end
时间: 2024-10-11 15:50:45