I want a custom id for each user. for example: "AG01" , i am working on asp.net web forms
Create custom id in sql using Asp.net Web forms
3 Answers
Know the answer? Post it. Somebody with the same question will find it here.
I want a custom id for each user. for example: "AG01" , i am working on asp.net web forms
Know the answer? Post it. Somebody with the same question will find it here.
Answer a question in the forums and earn +20 SHARP for every answer.
See unanswered questions
DevSocialUpcoming · 3rd editionAI Agents ConferenceDec 1–3, 2026Live onlineFree to attend5days leftRegister
Sachin SinghRank #66 · 26.2K reputationPosted Jan 2, 2023, 2:26 AM EST
The easiest way is to define the table such that you don't need to insert tha value manually from applictaion.
CREATE TABLE Test ( UserID VarChar(1000) AS 'FM'+Scope_Identity() ,Name Varchar(150) );Now, you don't need to enter the value of UserID
Vishal YelveRank #178 · 13.6K reputationPosted Jan 2, 2023, 7:14 AM EST
https://steemit.com/database/@virajtakke09/how-to-generate-unique-id-character-number-for-customer-in-sql-server
Puneet KankarRank #446 · 5.6K reputationPosted Jan 2, 2023, 10:46 AM EST
Hi Garima,
You can create functions or directly write these type code into stored proc.
https://www.sqlteam.com/articles/custom-auto-generated-sequences-with-sql-server
https://www.kodyaz.com/t-sql/custom-sequence-string-as-sql-identity-column.aspx
create function NextCustomerNumber() returns char(5) as begin declare @lastval char(5) set @lastval = (select max(customerNumber) from Customers) if @lastval is null set @lastval = 'AG0001' declare @i int set @i = right(@lastval,4) + 1 return 'AG' + right('000' + convert(varchar(10),@i),4) end