I have Table Like this In SQL server
I need a TRIGGER
FOR INSERT, UPDATE, DELETE
that ADD a new Row's in the same table like this:
In other mean for any row add to table by user that code start with 1xxx the trigger must inset to other row to that table whit code 8xxx & 9xxx.
with the same name.
thanks for your help.You could use an INSTEAD OF TRIGGER to do this. Code below should give you an idea of how to do this.
create trigger InsNewRows on tbl instead of insert
as
begin
insert into tbl (Code, Name)
select i.Code, i.Name from inserted as i
union all
select i.Code + n.Code, i.Name
from inserted as i
cross join (select 8000 union all select 9000) as n(Code)
where i.Code between 1000 and 1999
end|||Probably would want to use
where i.Code >= 1000 and cmpid <= 1999
No comments:
Post a Comment