Click here to Skip to main content
15,886,110 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
I have 2 Databases
1: ADB
2: BDB

ADB contains ADBTabe with 3/more fields
BDB contains BDBTabe with 3 fields fields

When the records inserted into "ADB.ADBTabe" then the job should be take data from that ADB table and insert into BDB.BDBTable

So could you please provide the approach that how to manage all these things.

What i have to implement sql server DB side?
How can i implement Windows / Any other job for this?

Could you please give me the proper suggestion.

What I have tried:

I have no idea about the scenario i am new
Posted
Updated 17-Jul-18 22:50pm
v2
Comments
dan!sh 29-Feb-16 5:21am    
Why not just run 2 insert queries?
[no name] 29-Feb-16 6:07am    
Do you want to run the service/job interval basis? Means it will run in every 5/10/.. minutes.

If answer is "no" then you don't need any job/windows to implement.
Sinisa Hajnal 29-Feb-16 6:34am    
Why not create linked servers and insert either directly from stored procedure (run two inserts in a transaction) or with OnInsert trigger?
DGKumar 1-Mar-16 4:26am    
Yes i want to create service or job to insert the data into another db table by using linked server by using stored procedure. Could you please provide the better approach or links to do it.

Write a webservice(can be WCF service) which will fetch data from BDB and insert data into BD.(Straight forward)


Now as soon as you update ADB.ADBTabe then trigger a notification to webservice. It will will fetch data from BDB and insert into BD.


Let me know if I you have any doubt.
 
Share this answer
 
Comments
DGKumar 29-Feb-16 23:28pm    
Thank you for your response.
I think every time the complete data will fetch and insert into destination source. Right?
Assume the source db table contain above 10000 records first time after that i have inserted one record in source then what will happen in destination db table, how can i identify and insert that particular newly inserted record only in destination db table.
Solution 1:
Create a column (say "updatedrow") by default which will be true. If you insert/update new row then set updatedrow to false for that record.

Solution 2:
Create a new table "xyz" which will hold primary key of newly updated row. later move the data by using primary keys present in the table xyz.



Solution 3: Run multiple queries to update both table, but it may degrade application performance.
 
Share this answer
 
v2
Comments
CHill60 3-Mar-16 7:06am    
Which one of your two solutions is supposed to be the answer?
Please don't post multiple solutions to the same question - it is very confusing. Instead use the Improve solution link to update your original solution.
May I suggest using SQL Dependency, see the article:

SQL Dependency with C#.NET and SQL Server 2012[^]

If you have a newer SQL Server version you can also use "Change tracking", see:

SQL Server Change Tracking on Table (Without Triggers)[^]
 
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