Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Synchronizing Two Database Tables Periodically

Status
Not open for further replies.

Cheryl3D

Programmer
Mar 26, 2002
116
0
0
US
Hi:
I have a problem to resolve regarding a table named UIC that is located in two separate SQL Server 2000 databases called 'DatabaseD' and 'DatabaseN'. Both of these databases are on the same server.

I want the UIC table in 'DatabaseN' to be synchronized with the UIC table in 'DatabaseD'-- so that any time the users add a new entry to a field called 'UIC_DESCR' in 'DatabaseD' the trigger on the UIC table in 'DatabaseN'will insert the same entry in its UIC table.
I thought that I might start by creating a trigger on 'DatabaseN' that looks like the following:

USE DatabaseD
CREATE TRIGGER checkUIC
ON UIC
AFTER INSERT, UPDATE
AS
IF UPDATE(UIC_DESCR)
--Remember the UIC_DESCR has already been inserted
INSERT INTO DatabaseN.dbo.UIC
WHERE UIC_DESCR IN (SELECT UIC_DESCR FROM DatabaseD.dbo.inserted)

Is this correct? Is this the best way to perfrom this task? Could DTS be used instead, and if so, please provide an coded example?

Any assistance would be greatly appreciated.

Thanks,
Cheryl




 
Not sure if it is the best but definitely an option. DTS will introduce a higher delay. Transactional replication is your other options...Though now I don't quite remember if you can subscribe to a publication on the same server.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top