Link to home
Start Free TrialLog in
Avatar of cesemj
cesemj

asked on

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

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.
ASKER CERTIFIED SOLUTION
Avatar of tim_cs
tim_cs
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of cesemj
cesemj

ASKER

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)
Avatar of EugeneZ
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
Avatar of cesemj

ASKER

Thanks , I will review and let you know.
Avatar of cesemj

ASKER

Thanks