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 |
poser
Posting Yak Master
124 Posts |
Posted - 2008-12-11 : 12:42:53
|
I have a table with two columnsBeginDate EndDateI ran a script to update BeginDate throught Query Analyzer(couple hundred rows were updated)Say a BeginDate was originally 11\30\2008 and I update it to 12/31/2009.There is a trigger that says when the BeginDate is updated mark the EndDate = to the update + 30 days.It works when I update it through the program..Do triggers fire through the Query Analyzer?Thanks for your helpR/P |
|
X002548
Not Just a Number
15586 Posts |
Posted - 2008-12-11 : 13:23:05
|
first, you could look in BOLsecond, triggers, like tables, are database objectsunlike tables they "fire" upon a specific DML operation (update, inerts, delete)The only control you have over triggers is how you code themthe only way I know to see them in action is through a tracedid that help any?Brett8-)Hint: Want your questions answered fast? Follow the direction in this linkhttp://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspxAdd yourself!http://www.frappr.com/sqlteam |
|
|
poser
Posting Yak Master
124 Posts |
Posted - 2008-12-11 : 18:33:27
|
I did look at BOL but I'm still confused.Maybe more info would help...First I update table1.BeginDate from Table3.CACDate WhereTable3.Email = Table1.EmailUPDATE Table1SET Table1.BeginDate=Table3.CACDateFROM Table1INNER JOIN Table3ON Table3.EMail=Table1.EmailSo After I update Table1.BeginDate shouldn't the following Trigger be shot off for every Table1.BeginDate that I update it should then update Table2.EndDate?Here is the trigger on Table1:Declare@id int,@BeginDate datetimeSELECT @id = EmployeeID,@BeginDate = BeginDateFROM insertedIf Update (BeginDate)BEGINUPDATE Table2SET EndDate = (@BeginDate + 30)WHERE EmployeeID = @idENDAgain, Thanks for any help\responsesR\P |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
X002548
Not Just a Number
15586 Posts |
|
|
|
|