--使用触发器就成了------------------------建立触发器----------------------------create trigger dbo.tri_Test
on Test for insert
as
if @@rowcount=0
return
update a
set a.status=1
from Test a join inserted b
on a.[id]=b.[id]
where b.content is null
Go
on Test for insert
as
if @@rowcount=0
return
update a
set a.status=1
from Test a join inserted b
on a.[id]=b.[id]
where b.content is null
Go
as
begin
declare @a varchar(1000)
declare @b int
select @a=content from inserted
select @b=status from inserted
select @c=id from inserted
if (@a is null) or (@a not between 0 and 99999999999)
begin
select @b = 1
end
insert into test(id,content,status) select @c,@a,@b
end
go
--自己再修改下吧!~
create table Test
(
id int,
content varchar(10),
status bit
)CREATE TRIGGER TEMP_SC on Test
INSTEAD OF Insert
as
declare @T table(id int,content varchar(10),status bit)
insert @T select * from inserted
update @T set status=1 where isnull(content,'')=''
insert Test select * from @T
insert Test select 1,'',0
union select 2,'sdsd',0
union select 3,Null,0select * from Test