Auto Generate Alpha numeric ID in SQL server

Posted by Kirthiga under Sql Server category on | Points: 40 | Views : 2183
Declare @table table(Name varchar(10))
insert into @table values('Ram'),('Kamal'),('Suresh'),('Vinoth'),('Surya'),('Vijay'),('Siva')
select *,concat(Name,REPLICATE('0',6-len(Name)), Format(ROW_NUMBER()over(order by Name),'000'))DocNo from @table

Comments or Responses

Posted by: Rajnilari2015 on: 5/23/2018 Level:Platinum | Status: [Member] [Microsoft_MVP] [MVP] | Points: 10
this can be achieve by using NEWID() provided you are not looking for sequential numerics

Login to post response