我有作为 ReasonMaster 的表
ReasonId nchar(10),Reason varchar(50),EntLog datetime.
内容为:
ReasonId Reason
--------- -------
REA00001 Ask For Leave
添加新记录后,我必须自动生成下一个 ReasonId 列作为 REA00002
我有作为 ReasonMaster 的表
ReasonId nchar(10),Reason varchar(50),EntLog datetime.
内容为:
ReasonId Reason
--------- -------
REA00001 Ask For Leave
添加新记录后,我必须自动生成下一个 ReasonId 列作为 REA00002
您可以像这样生成下一个 id
select 'REA' + right('00000' + cast(max(right(ReasonId, 5)) + 1 as varchar), 5)
from ReasonMaster