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 |
|
cdene
Starting Member
1 Post |
Posted - 2005-09-21 : 16:43:41
|
| I am new to sql triggers and tried to create one that updates a date field but what it does is add a new row with the update field.can someone please help me fix this?CREATE TRIGGER Tg_Update_close ON [dbo].[tblTicket] for UPDATEASinsert into tblticket (datecomplete)select getdate() |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
Posted - 2005-09-21 : 16:48:32
|
| You need to use the inserted trigger table to determine what rows were updated. You join to that to update those specific rows. Check out deleted and inserted trigger tables in SQL Server Books Online if you aren't familiar with them.CREATE TRIGGER utrg_tblTicketON [dbo].[tblTicket] FOR UPDATEASUPDATE tSET datecomplete = GETDATE()FROM tblticket tINNER JOIN inserted i ON t.YourPKColumn = i.YourPKColumnTara |
 |
|
|
|
|
|