Please start any new threads on our new
site at https://forums.sqlteam.com. We've got lots of great SQL Server
experts to answer whatever question you can come up with.
| Author |
Topic |
|
Leonius
Starting Member
7 Posts |
Posted - 2011-08-25 : 06:29:03
|
| Two tables,T1 holds Location, gamestocklevel, gamename, dateStocked,T2 holds historical data from t1 so same columns,UniqueID, Location, gamestocklevel, gamename, dateStocked,The UniqueID column which is a seeded autonumber to keep records unique,What I want to do is if the gamename, on table 1 is updated (say for instance the game name changes so its now different stock in that location)I want to insert a new row on t2, Location, gamestocklevel, gamename, dateStocked,I cant seem to get this one to work. |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2011-08-25 : 06:33:44
|
something likeCREATE TRIGGER Trg_Update ON T1AFTER UPDATEAS BEGININSERT INTO T2 (Location, gamestocklevel, gamename, dateStocked)SELECT Location, gamestocklevel, gamename, dateStockedFROM INSERTED iJOIN DELETED dON d.PK = i.PKWHERE d.gamename <> i.gamenameEND PK is primary key of T1------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/ |
 |
|
|
|
|
|
|
|