Click here to Skip to main content
15,889,216 members
Home / Discussions / Database
   

Database

 
GeneralAutomatic email sending function Pin
Jamman19-Feb-08 19:50
Jamman19-Feb-08 19:50 
GeneralRe: Automatic email sending function Pin
Steven J Jowett20-Feb-08 4:52
Steven J Jowett20-Feb-08 4:52 
Generalsql inserting Pin
mrcsn19-Feb-08 18:12
mrcsn19-Feb-08 18:12 
GeneralRe: sql inserting Pin
Krish - KP19-Feb-08 20:12
Krish - KP19-Feb-08 20:12 
GeneralCopy data In table [modified] Pin
kibromg19-Feb-08 6:08
kibromg19-Feb-08 6:08 
GeneralRe: Copy data In table Pin
Mark J. Miller19-Feb-08 7:50
Mark J. Miller19-Feb-08 7:50 
GeneralRe: Copy data In table Pin
kibromg19-Feb-08 9:19
kibromg19-Feb-08 9:19 
GeneralRe: Copy data In table Pin
Mark J. Miller19-Feb-08 11:16
Mark J. Miller19-Feb-08 11:16 
Does the data in the production table change at all (UPDATE/DELETE)? Or is it always new data (INSERT)?

One answer is to use Red Gate's SQL Data Compare. It's pretty cheap and you can write a script to sync the tables every two hours.

You could dump/refresh the backup table.

Method 1:
This would work much like using the Red Gate tool.

1) Add a timestamp column to the livedata table and a binary column to the backupdata table
2) Compare and update existing data (UPDATE b SET column = live.column FROM backupdata b INNER JOIN livedata live ON live.ID = B.ID WHERE live.stamp <> b.stampcopy)
3) Insert all data from livedata that doesn't exist in backupdata

Method 2:

1) Create a logging table that records which records in livedata have changed and the change that was made (INSERT, UPDATE, DELETE).

2) Create a trigger on livedata would add a record to the logging table including ID, Action, ActionTime. (ActionTime could be a timestamp or datetime).

3) Write a script that reads the log table, and syncs the backupdata table on a schedule based on the ID and the action with the oldest ActionTime.

Method 3:

TRUNCATE TABLE backupdata<br />
INSERT INTO backupdata (columns)<br />
SELECT columns FROM livedata


Method 4:

CREATE TABLE backupdata_temp (<br />
 columns.....<br />
)<br />
<br />
INSERT INTO backupdata_temp (columns)<br />
SELECT columns FROM livedata<br />
<br />
DROP TABLE backupdata<br />
<br />
EXEC sp_rename ......


Either way make sure you wrap the whole thing in a transaction and set the logging mode to BULK LOGGED before you do it and then change the logging mode back when you're done. Also, if you use method 3, make sure you recreate any indexes you had that were on the backup table.

The choice of methods will depend on the availability requirements for the backup table and the amount of data you're working with.


GeneralRe: Copy data In table Pin
kibromg19-Feb-08 23:21
kibromg19-Feb-08 23:21 
GeneralRe: Copy data In table Pin
kibromg19-Feb-08 23:48
kibromg19-Feb-08 23:48 
GeneralRe: Copy data In table Pin
Mark J. Miller20-Feb-08 6:54
Mark J. Miller20-Feb-08 6:54 
GeneralAPPLICATION TO RUN EVERY FEW SECONDS Pin
kibromg21-Feb-08 5:27
kibromg21-Feb-08 5:27 
QuestionAdvice sought, how do I best handle saving an array in a SQL database? Pin
Per Sderberg19-Feb-08 5:06
Per Sderberg19-Feb-08 5:06 
GeneralRe: Advice sought, how do I best handle saving an array in a SQL database? Pin
Mark J. Miller19-Feb-08 8:26
Mark J. Miller19-Feb-08 8:26 
GeneralRe: Advice sought, how do I best handle saving an array in a SQL database? Pin
Per Sderberg19-Feb-08 21:41
Per Sderberg19-Feb-08 21:41 
QuestionHow do I merge data into one record Pin
KreativeKai19-Feb-08 4:16
professionalKreativeKai19-Feb-08 4:16 
GeneralRe: How do I merge data into one record Pin
Mark J. Miller19-Feb-08 8:12
Mark J. Miller19-Feb-08 8:12 
Questionimages in ms-access database. Pin
avvaru.murali19-Feb-08 2:43
avvaru.murali19-Feb-08 2:43 
GeneralRe: images in ms-access database. Pin
Kschuler19-Feb-08 10:49
Kschuler19-Feb-08 10:49 
Questionembedded database Pin
avvaru.murali19-Feb-08 2:36
avvaru.murali19-Feb-08 2:36 
GeneralRe: embedded database Pin
Colin Angus Mackay19-Feb-08 4:24
Colin Angus Mackay19-Feb-08 4:24 
GeneralProblem with update statement. Pin
matjame19-Feb-08 1:59
matjame19-Feb-08 1:59 
GeneralRe: Problem with update statement. Pin
Mark J. Miller19-Feb-08 8:32
Mark J. Miller19-Feb-08 8:32 
QuestionHow to retrive the transactions back using log files Pin
Satish - Developer18-Feb-08 23:07
Satish - Developer18-Feb-08 23:07 
AnswerRe: How to retrive the transactions back using log files Pin
Mark J. Miller19-Feb-08 8:35
Mark J. Miller19-Feb-08 8:35 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.