Author |
Topic |
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2007-12-26 : 03:22:59
|
i need to create a trigger so i can get the orginal values in a separate table to track changes, both table r same in column structrehow can i create a trigger After Updatetable Orignal name: emplyeeORGtable Track name: employeeTRKID FirstName LastName1 abc xyz2 fgh ijk |
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2007-12-26 : 04:39:56
|
[code]CREATE TRIGGER Employee_Trg_Upd ON emplyeeORGAFTER UPDATE ASINSERT INTO employeeTRKSELECT ID,FirstName,LastName FROM DELETEDGO[/code] |
|
|
lionofdezert
Aged Yak Warrior
885 Posts |
Posted - 2007-12-26 : 06:29:55
|
Thanx a lot dear...actually i was using FROM UPDATED (and that was my mistake)thanx again |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2007-12-26 : 06:44:31
|
There is no internal table called UPDATED. The update is actually handled internally as a DELETE followed by INSERT so that you will get old values in DELETED and new values in INSERTED table after an update operation |
|
|
pzn3xq
Starting Member
1 Post |
Posted - 2008-01-14 : 15:53:53
|
Hi, I have two questions.1) Is there a way to automatically determine which field changed from the orginal table? Lets you want to capture just first name, or last name rather than all fields.2) Is there a way to take the single field changed from above, and insert that into your employeeTRK table?Thanks,John |
|
|
unique_rehan
Starting Member
2 Posts |
Posted - 2009-07-23 : 07:11:02
|
i have two different databases and udpate two table from one of each database as insert a value in a data base's table than other updated its data automatically |
|
|
swatip
Starting Member
8 Posts |
Posted - 2009-12-29 : 04:47:44
|
I didn't understand the UPDATED and INSERTED tables concept.Anyone can please help? |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
Posted - 2009-12-29 : 04:55:22
|
There are two special virtual tables in MSsql server1.Inserted2.Deleted These tables are affected as below when a DML Statement hits your table.1.Insert statement -> New record inserted -> Insert table2.Update Statement -> Old record is deleted and new record is inserted -> Deleted,Inserted Tables3.Delete statement ->Old record is deleted ->Deleted tableSenthil.C------------------------------------------------------[Microsoft][ODBC SQL Server Driver]Operation canceledhttp://senthilnagore.blogspot.com/ |
|
|
senthil_nagore
Master Smack Fu Yak Hacker
1007 Posts |
|
rajdaksha
Aged Yak Warrior
595 Posts |
|
aaabbb
Starting Member
2 Posts |
Posted - 2014-03-19 : 03:01:12
|
Create triggers and assertions for Bank database handling deposits and loan and admission database handling seat allocation and vacancy position. Design the above relational database schema and implement the following triggers and assertions.a. When a deposit is made by a customer, create a trigger for updating customers account and bank accountb. When a loan is issued to the customer, create a trigger for updatingcustomer’s loan account and bank account.c. Create assertion for bank database so that the total loan amount does not exceed the total balance in the bank.d. When an admission is made, create a trigger for updating the seat allocation details and vacancy position. |
|
|
|