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 |
TheDutchBeast
Starting Member
2 Posts |
Posted - 2014-10-20 : 07:30:35
|
Hello, for my school I am making an app which has a trigger, the trigger is called when a database value changes. ( working with SQL 2008 R2 )A complete filtered timetable file is imported in the database ( works )The new filtered timetable file ( with changes ) will be imported via an UPDATE, and the values that are changed ( for example "English at 12:00" becomes "English at 13:00 ). At that time I want a trigger.How do I make this happen?Via this trigger, the app will send a push message later, but first the database trigger has to work.Thanks in AdvanceXamarin Rocks! |
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-10-20 : 08:55:44
|
Good reference here: http://msdn.microsoft.com/en-us/library/ms189799.aspxBasically you want:CREATE TRIGGER [MyTrigger] ON [MyTable]AFTER UPDATE ASIF UPDATED([MyColumn]) BEGIN-- push your messageENDBe aware that, depending on how your table is updated, you may have more than one updated row causing the trigger to fire. In such a case, use the special logical tables "inserted" and "deleted" to determine what changed and act accordingly |
|
|
TheDutchBeast
Starting Member
2 Posts |
Posted - 2014-10-20 : 09:20:21
|
The push past will be done in the app.I just want a list on the changed values in the database ( via the trigger )Xamarin Rocks! |
|
|
gbritton
Master Smack Fu Yak Hacker
2780 Posts |
Posted - 2014-10-20 : 09:31:14
|
OK -- same basic idea. Just send your updated rows somewhere for the app to pick up. e.g.insert into [table to capture updated rows](columns)select * from inserted |
|
|
|
|
|