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 |
|
shajimanjeri
Posting Yak Master
179 Posts |
Posted - 2008-02-03 : 09:30:40
|
| Dear all,I have a table named Messages with fieldsId numericSmsBody varchar(4000)mobilenumber varchar(15)Status char(1).and also there is another table named MsgHistory with fields Id numericMsgId numeric -- (will be the Id from table Messages)SmsBody varchar(4000)Status char(1).I need to work a trigger if any new message (record) is inserted into table Messages, at the same time the trigger should execute to insert MsgId and SmsBody to table MsgHistory from table Messages.How I can write trigger for this?with regardsShaji |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2008-02-03 : 09:43:19
|
| CREATE Trigger MessageAuditON Messages AFTER INSERT ASINSERT INTO MsgHistory(MsgId,SmsBody,Status)SELECT i.MsgId,i.SmsBody,i.StatusFROM INSERTEDGO |
 |
|
|
|
|
|