|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
|
|
Stay one step ahead of the competition. Evaluate and give feedback
on some of the hottest web development tools on the market today.
Make your opinion heard! Click
Here
|
|
#1
|
|||
|
|||
|
I have a Table Called tblEmpl and another called tblTrackEmpl
I want that whenever a record is inserted for any New Employee in the tblEmpl table it should be Inserted to the tblTrackEmpl table. Thereafter when ever the details (for eg:emplcode) of that particular Employee is Updated (Only when Updated) in the TblEmpl Table it should be added(a new record) to the tblTrackEmpl table. i wrote Two Trigger onr for INSERT and other for UPDATE which is as follows CREATE TRIGGER EMPL_INSERT ON tblEmpl AFTER INSERT AS IF @@ROWCOUNT=0 RETURN INSERT tblTrackEmpl SELECT * FROM inserted CREATE TRIGGER EMPL_update ON tblEmpl AFTER UPDATE AS declare @id1 int begin select @id1=id from inserted IF update(emplcode) and (select count(*) from Inserted) = 1 INSERT tblTrackEmpl SELECT * FROM tblEmpl where id=@id1 End But when ever i Just Click Update from the FrontEnd evenif i dont make anychanges to that record a new record is inserted to the tblTrackEmpl Table What could be the solution Thanx in Advance |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Database Development > Update and Insert Triggers |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|