CREATE TABLE PaperTable( PaperID int IDENTITY (1,1) NOT NULL , PageNumber varchar(100) , PaperAlphaID AS Cast(Right(Year(getDate()),2) as varchar(2)) +'-'+ PageNumber); 当我添加“001”和“002”作为我的纸号时,我得到了结果
CREATE TABLE PaperTable ( PaperID int IDENTITY (1,1) NOT NULL , PageNumber varchar(100) , PaperAlphaID AS Cast(Right(Year(getDate()),2) as varchar(2)) +'-'+ PageNumber );
当我添加“001”和“002”作为我的纸号时,我得到了结果:
PaperID PageNumber PaperAlphaID ------- ---------- ------------ 1 001 15-001 2 002 15-002
但我想在PaperAlphaID中全年展示
PaperID PageNumber PaperAlphaID ------- ---------- ------------ 1 001 2015-001 2 002 2015-002
而不是15-001和15-002
删除RIGHT函数并更新varchar(4)CREATE TABLE PaperTable ( PaperID int IDENTITY (1,1) NOT NULL , PageNumber varchar(100) , PaperAlphaID AS Cast(Year(getDate())) as varchar(4)) +'-'+ PageNumber );