SQL Server - COPYING DATA FROM ANOTHER DATABASE AT SIMULTANEOUSLY
Asked By kumar on 14-Feb-12 06:00 AM
HOW TO INSERT THE RECORD IN ONE DATABASE TABLE AND IT SIMULTANEOUSLY INSERT INTO ANOTHER DATABASE TABLE.
for example,
StudentDetails table in STUDENT database and StudentInfo in Employee database and i want to insert record on StudentDetails same time the record should be inserted into studentInfo in Employee database
Venkat K replied to kumar on 14-Feb-12 06:19 AM
Inserting records to multiples database at same time is practically not possible, you need to use Transactions to maintain synchronization between two databases
BEGIN
TRY
BEGIN TRAN T1
USE Student
INSERT INTO StudentInfo SELECT * from tblname
USE Employee
INSERT INTO StudentDetails SELECT * from tblname
COMMIT TRAN T1
CATCH
ROLLBACK TRAN T1
END TRY
hope this helps!