当前位置 : 主页 > 编程语言 > c语言 >

vb.net – 计算列规范

来源:互联网 收集:自由互联 发布时间:2021-06-24
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
);
网友评论