c# - i want to make conditional trigger in sql server...... -


i have table named test , table named trigg..... want is.... whenever data having 'name' 'rakesh' being inserted test...it should fire trigger insert age in 'trigg' table....

i tried self.... chk it...

create trigger trigger1  on test after insert if((select name test) 'rakesh') begin  insert trigg(age) select name test end 

but didnt worked.. whenever inserting in test ..getting error :

subquery returned more 1 value. not permitted when subquery follows =, !=, <, <= , >, >= or when subquery used expression. 

help me out....

  • you selecting test when should selecting inserted. want statements take effect based on being inserted, not based on table may contain.

  • even after changed, trigger fires once per statement, not once per row. if insert affects multiple rows, inserted pseudotable contain multiple rows, , subselect therefore fail.

suggested revision:

create trigger trigger1  on test after insert if exists (select * inserted name 'rakesh') begin      insert trigg(age)     select name inserted      name 'rakesh' end 

Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -