Trigger Execution Problem

Posted by mareesnectar-12158 under Sql Server on 12/19/2011 | Points: 10 | Views : 881 | Status : [Member] | Replies : 1
create table emp (sno int primary key,name varchar(10),salary int)
---
--
create trigger salary_trigger
on Emp
for INSERT
AS

insert into emp (sno,name,salary)
select sno,name,salary

FROM Emp where Salary > 5000

go
--
--
insert into Emp values(11,'marrr',500) This query inserted successfully( didnt show the error)

all are executed successfully..
but trigger condition didnt check




Responses

Posted by: mareesnectar-12158 on: 12/20/2011 [Member] Starter | Points: 25

Up
0
Down
NOW I GOT THE ANSWER...... ANY WAY THANKS ....


create trigger salary_trigger
on Emp
instead of INSERT
AS
begin
declare @salary as int
declare @sno as int
declare @Company_name as varchar(50)
declare @sname as varchar(50)
select @salary=salary,@sno=sno,@Company_name=Company_name,@sname=name from inserted
if(@salary>8000)
begin
insert into emp values(@sno,@sname,@Company_name,@salary)

end
else
print'Enter more than 8000'
end

mareesnectar-12158, if this helps please login to Mark As Answer. | Alert Moderator

Login to post response