如何通过触发器防止插入重复数据
1个回答
展开全部
create trigger t_insert_tabName
on tabName
instead of insert
as
declare @columnvalue int
set @columnValue=
(select columnValue from inserted)
if exists(select * from tabName where columnName=@columnValue)
rollback
else
insert into tabName select * from inserted
on tabName
instead of insert
as
declare @columnvalue int
set @columnValue=
(select columnValue from inserted)
if exists(select * from tabName where columnName=@columnValue)
rollback
else
insert into tabName select * from inserted
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询