Solved

Develop a automated script to copy data from one DB table to the same table in another DB

Posted on 2014-01-14
5
262 Views
Last Modified: 2014-02-05
Platform
1: Windows server 2008 R2
2: SQL server 2008 R2

Hi,

I have 2 server environments (ENV-A and ENV-B)  running SQL server 2008 R2 and I would like to copy records from DB_A.dbo.table1(ENV-A) and append them to the DB_B.dbo.table1(ENV-B) every 15mins.  

Problem:
How to copy data between DBs over the network every 15 mins.
How to append records if the SS# data field in table 1 on ENV-B is null.

Please share with me any articles / examples about how to copy records from one DB to another DB.

Thanks in advance.
0
Comment
Question by:cesemj
  • 3
5 Comments
 
LVL 15

Accepted Solution

by:
tim_cs earned 500 total points
Comment Utility
Have you looked into using replication?

If that is not an option can you provide the table schema?  Are you wanting to just move new inserts or are their updates and deletes as well?  You mention something about the SS#, is that the primary key?
0
 

Author Comment

by:cesemj
Comment Utility
I have not looked into replication but I will.  What I am tying to accomplish is anytime a record is added it table1 in ENV-A the record is automatically copied to table1 in ENV-B only if the record does not exist or have the SS# (social security number) filled in.  

Table Schema
AwardID                              int                             
FirstName                           nvarchar(100)      
LastName                           nvarchar(100)      
EmailAddress                           nvarchar(100)      
PhoneNumber                   nvarchar(50)      
AwardOption                      nvarchar(10)      
Fax                                           nvarchar(50)      
OrgCNo                                   nvarchar(50)      
OrgName                           nvarchar(200)      
OrgType                             nvarchar(50)      
OrgTypeII                          nvarchar(100)      
ProfessionalDesc                   nvarchar(200)      
Other                                   nvarchar(300)      
BusinessAddress                   nvarchar(MAX)      
City                                           nvarchar(100)      
State                                   nvarchar(10)      
ZipCode                                   nvarchar(10)      
regAwardDate                   datetime      
AwardNo                           nvarchar(3)      
regConfirmationDate           nvarchar(50)      
Status                                   nvarchar(15)      
regAttendance                   nvarchar(15)      
Note                                        nvarchar(MAX)
SS#                                           nvarchar(6)      
StatusReason                           nvarchar(MAX)      
AwardNoStatus                   nvarchar(3)
0
 
LVL 42

Expert Comment

by:EugeneZ
Comment Utility
if you need  the near 'real-time" solution
and data be available to "read"  on the "subscriber" ,
as per above post use replication :

data on the 2nd server will be almost immediately changed if on the 1st it was changed

Transactional Replication can be your choice, just make sure the table has  PK
http://technet.microsoft.com/en-us/library/ms151176(v=sql.105).aspx
0
 

Author Comment

by:cesemj
Comment Utility
Thanks , I will review and let you know.
0
 

Author Closing Comment

by:cesemj
Comment Utility
Thanks
0

Featured Post

Control application downtime with dependency maps

Visualize the interdependencies between application components better with Applications Manager's automated application discovery and dependency mapping feature. Resolve performance issues faster by quickly isolating problematic components.

Join & Write a Comment

Use this article to create a batch file to backup a Microsoft SQL Server database to a Windows folder.  The folder can be on the local hard drive or on a network share.  This batch file will query the SQL server to get the current date & time and wi…
Load balancing is the method of dividing the total amount of work performed by one computer between two or more computers. Its aim is to get more work done in the same amount of time, ensuring that all the users get served faster.
Via a live example, show how to extract information from SQL Server on Database, Connection and Server properties
Using examples as well as descriptions, and references to Books Online, show the different Recovery Models available in SQL Server and explain, as well as show how full, differential and transaction log backups are performed

763 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now