Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 Taking simple table backup

Author  Topic 

Kimi86
Yak Posting Veteran

79 Posts

Posted - 2014-08-12 : 18:06:54
I have a table say my_table with few columns such as below
ID, col1,col2,col3,col4 - ID is identity and pk
I need to back this table up on regular basis.Once in 3 months

So i created a backup table called my_table_bak with columns
ID, col1,col2,col3,col4, Timestamp- ID is not identity. Timestamp is defaulted to getdate()

if i need to reload the table my_table with recent backup i thought I would use the Timestamp column. But in case the back ups were taken very quickly say almost immediately after the first and not after 3 months,it would become difficult for me to figure the recent set of data. What is the cleanest way to deal with this problem. Is it a good idea to insert a all NULL row to the table to differentiate between the sets.

Also the data in my_table_bak is all jumbled up because it had no primary key. Should i put in pk,identity

Thanks,

djj55
Constraint Violating Yak Guru

352 Posts

Posted - 2014-08-13 : 09:16:32
Inserting an "all NULL" will not do as SQL Server does not save data records as you might think.

What I would suggest is have a stored procedure where you define the datetime to input into Timestamp as a variable for each backup. That way all records would have the same datetime.

djj
Go to Top of Page
   

- Advertisement -