日期:2014-05-17 浏览次数:20620 次
go if OBJECT_ID('test')is not null drop table test go create table test( A char(5), B char(2), C int ) go insert test select 'b1101','b1',101 --按照你的要求建立触发器 go if OBJECT_ID('tri_tracy')is not null drop trigger tri_tracy go create trigger tri_tracy on test instead of insert as declare @A char(5),@B char(2),@C int select @B=B from inserted select @A=@B+ltrim(max(C)+1),@C=max(C)+1 from test insert test values(@A,@B,@C) go insert test(B) select 'B2' select * from test /* A B C b1101 b1 101 B2102 B2 102 */