Click here to Skip to main content
15,915,869 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi!
I have two database with same name and fields. There I have MessageTransaction table.
I want to create such trigger that whenever data inserted into table of database A
it should automatic insert that data into database B.

Following in MessageTransaction table fields.

MessageID numeric(10, 0) Unchecked
ChannelNo numeric(3, 0) Checked
ExtensionNo nvarchar(50) Checked
IPAddress nvarchar(50) Checked
MessageFileName nvarchar(255) Checked
MessageDate datetime Checked
CallerId nvarchar(50) Checked
InOutFlag int Checked
PlayPath nvarchar(255) Checked
Information char(25) Checked

How to do this ???
Posted

1 solution

Hi Ravi Sharma,

Try this...

SQL
ALTER TRIGGER InsertMsgTransaction ON DB1.dbo.MessageTransaction
   FOR INSERT
AS 

INSERT INTO DB2.dbo.MessageTransaction SELECT * FROM INSERTED

GO


Thank you
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900