You can embed a sequence value into a custom-formatted string in a default, and enforce it with a check constraint. Like this:
--drop table if exists Employee
--drop sequence seq_Employee
--go
create sequence seq_Employee
start with 1
increment by 1
go
CREATE TABLE Employee
(
EmployeeCode char(5) PRIMARY KEY
default 'E' + format((next value for seq_Employee),'0000' )
check (EmployeeCode like 'E[0-9][0-9][0-9][0-9]'),
EmployeeName VARCHAR(50) NOT NULL
)
go
insert into Employee(EmployeeName)
values ('A'),('B'),('C'),('D'),('E')
select *
from Employee
Outputs
EmployeeCode EmployeeName
------------ --------------------------------------------------
E0001 A
E0002 B
E0003 C
E0004 D
E0005 E
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…