Dear Sir
How to create employee id number auto increment number like EMP1001
give example script coding
Auto Identiy
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
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 attend4days leftRegister
Pravin GhadgeRank #1,340 · 1.3K reputationPosted Dec 20, 2011, 1:49 AM EST
try this:
declare @temp as char(15)
set @temp=(select max(right(Itemcode,6)) + 1 from tblname
where (left(itemcode,3)='EMP'
set @temp='EMP'+isnull(replicate(0,6-len(@temp)),'')+@temp
select isnull(cast(@temp as char(15)),'EMP100001')
shubhangi khandale55 reputationPosted Dec 20, 2011, 11:15 PM EST
Write following formula for this if u use sql server then to go this column property computed column specification then write
formula ((''EMP+left([empID,(5)))+convert([varchar],[empid],(0)))
and
is Persisted =yes