declare @count int; declare @order varchar(8); declare @zero int;declare @temp varchar(8); declare @num int; select @count=1 set @zero=7-len(@count+1); if(@zero>0) begin set @num=0; set @temp=''; while @num<@zero begin set @temp=@temp+'0'; set @num=@num+1; end set @order='8'+@temp+convert(varchar(8),@count+1 ); end; print @order
规则:以8开通的订单号
各位有更好的做法,请告知,我将不胜感谢。