Chat LIVE With Programming Experts! There Are 23 Online Right Now...

Welcome to Dream.In.Code
Become an Expert!

Join 244,307 Programmers for FREE! Get instant access to thousands of experts, tutorials, code snippets, and more! There are 789 people online right now. Registration is fast and FREE... Join Now!




MS SQL 2005 Backups

 
Reply to this topicStart new topic

MS SQL 2005 Backups, Transaction, I think their called?

gymratz
19 Nov, 2008 - 12:15 PM
Post #1

D.I.C Head
**

Joined: 18 Oct, 2007
Posts: 102


My Contributions
My goal:
Have a history going back a week that stores all changes every x amount of minutes (I'm thinking 30-60).

Reason:
We back up the SQL database to tape nightly; however, if anything is ever deleted or missing I want to know it was saved more recently than to tape to restore from that.

I'm pretty sure there is a built in way to do this - but I am a noob. Can anyone point me in the correct direction?

Thanks,

User is offlineProfile CardPM
+Quote Post


eclipsed4utoo
RE: MS SQL 2005 Backups
19 Nov, 2008 - 12:45 PM
Post #2

D.I.C Lover
Group Icon

Joined: 21 Mar, 2008
Posts: 1,170



Thanked: 117 times
Dream Kudos: 125
My Contributions
you will want to do a "differential" backup.

http://msdn.microsoft.com/en-us/library/ms181092.aspx

User is offlineProfile CardPM
+Quote Post

Trogdor
RE: MS SQL 2005 Backups
20 Nov, 2008 - 03:13 AM
Post #3

D.I.C Addict
Group Icon

Joined: 6 Oct, 2006
Posts: 609



Thanked: 11 times
Dream Kudos: 200
My Contributions
No, i think he is referring to a history system.
For each table that you want to track in this way, you will need a 'shadow' or 'history' table next to it to record the changes in.
Say that a table you want to track is
CODE

Table Users:
ID int pk,
Username varchar(250),
RegisterDate DateTime;


Then you historytable could be something like
CODE

Table Users_History:
HistoryID int pk,
ChangeType char(1),
ChangeMoment DateTime,
ID int,
Username varchar(250),
RegisterDate DateTime;


Optionaly you can also add for example a UserID or something to track who was the one that did it.
Note that the primary key from the original table is no longer a primary key. It will even contain duplicates.
To access the reccords in a good fashion a new pk is added that should (also) be a sequence.

Now on the original Users table you will need to make some triggers.
On every insert, update or delete you should insert a reccord into the history table containing the NEW values. (not the old ones, those should already be there from the insert!)
With the delete trigger ofcourse NULLs should be inserted as new values.


I hope this helps.
User is offlineProfile CardPM
+Quote Post

Fast ReplyReply to this topicStart new topic

Time is now: 7/4/09 06:51PM

Live Help!

Be Social

Dream.In.Code RSS Feed Dream.In.Code LinkedIn Group Follow Us On Twitter Fan Us On Facebook

Tutorials

Programming

Web Development

Reference Sheets

Code Snippets

DIC Chatroom

Bye Bye Ads

Monthly Drawing

Thumb Drive

Top Contributors

Top 10 Kudos This Month