1 DECLARE @r numeric(15,8) 2 DECLARE @tempStr char(10) 3 select @r=RAND((DATEPART(mm,GETDATE())*100000)+(DATEPART(ss,GETDATE())*1000)+DATEPART(ms,GETDATE())+cast( floor(rand()*100) as int)) 4 SET @tempStr=@r 5 select '132'+SUBSTRING(@tempStr,3,4)+SUBSTRING(@tempStr,7,4)