create trigger tr_insert on table
for insert
as
BEGIN
begin trans
update table set 档案号='H'+right('0000'+cast(right(档案号,4)+1 as varchar(4),4) where 档案号>=@新档案号
insert 表 values(@新档案号,.....)
commit trans
END
create trigger tr_insert table
for insert
as
if exists( select 档案号 from table where 档案号=inserted.档案号)
update table set 档案号='H'+cast(right(档案号,4)+1 as varchar(4)) where 档案号>=inserted.档案号
支持大力的,真够快的
create procedure InsertDocumentID(@newID varchar(10)) as
BEGIN
begin trans
update DOCTable set DocID='H'+right('0000'+cast(right(档案号,4)+1 as varchar(4),4) where 档案号>=@新档案号
insert 表 values(@新档案号,.....)
commit trans
END