SQLTeam.com | Weblogs | Forums

Increment id in table

sql2008r2

#1

Dear sir
Goodmorning.
I have two table, one is TBL_EMP and second is TBL_DEPARTMENT
TBL_EMP
EMPID, DEPTID, EMPNAME, DOJ, DOB .....

TBL_DEPARTMENT
DEPTID, DEPTNAME

DEPTNAME are executive, developer

I have require empID ex1001, dev1002, and so on.............


#2

You can add identity column in TBL_Emp and make EmpID as computed column which will have values combined of DeptID and Identity Column. It's better to make computed column persisted for better performance.