写触发器: create trigger aaa on text for insert AS update Test set NewID='OLD'+right('00000'+cast(id as varchar(5)),5) where ID in (select ID from inserted)
--用计算列就可以了: alter table 你的表 add NewID as 'OLD'+right('0000'+cast(id as varchar),4)
right('0000'+cast(id as varchar),4)不满四位的,左侧用0填充。又学了一招! :)
create trigger aaa on text
for insert
AS
update Test
set NewID='OLD'+right('00000'+cast(id as varchar(5)),5)
where ID in (select ID from inserted)
alter table 你的表 add NewID as 'OLD'+right('0000'+cast(id as varchar),4)
:)