create trigger Default_author on article after insert as begin update article set author ='佚名' where author is null end每次插入的时候都把author为空的行更新下,就行了,不需要判断 我的理解
--這種問題一般不用trigger,用默認值比較好 alter table article add constraint [DF_article_author] default ('佚名') for author go
on article
after insert
as
begin
update article set author ='佚名' where author is null
end每次插入的时候都把author为空的行更新下,就行了,不需要判断
我的理解
--這種問題一般不用trigger,用默認值比較好
alter table article add constraint [DF_article_author] default ('佚名') for author
go