当前位置: 代码迷 >> ASP.NET >> sql的触发器运用
  详细解决方案

sql的触发器运用

热度:6459   发布时间:2013-02-25 00:00:00.0
sql的触发器使用
我想在数据库插入数据的时候,如果那一列没有插入则显示为‘佚名' 
create TRIGGER Default_author 
  ON article 
  after INSERT
AS 
BEGIN
if((select author from article where author is null)>=0)
BEGIN
update article set author='佚名' where author is null
END
END
GO


------解决方案--------------------------------------------------------
楼上的应该就行啦
------解决方案--------------------------------------------------------
SQL code
--這種問題一般不用trigger,用默認值比較好alter table article add constraint [DF_article_author] default ('佚名') for authorgo
  相关解决方案