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.
Author |
Topic |
bigmac072889
Starting Member
3 Posts |
Posted - 2008-04-01 : 14:04:46
|
Hello,We are running MS-SQL 2000 and how it is setup is that customers will work in there database and at varying lengths of time create new databases from the old. We only need to have a backup of that most recent database, but we are having to do it manually as the name changes when the new database is created. Does anyone know how to setup a job that would backup the most recently created database and delete the old backup file from the previous one.Any help would be greatly appreciated! |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-04-01 : 14:59:17
|
You can use Dynamic SQL for this:You can get most recently created database withselect name from sysdatabases where datediff(hour,crdate,getdate())< 1( created within 1 hour) |
 |
|
bigmac072889
Starting Member
3 Posts |
Posted - 2008-04-01 : 15:07:13
|
Is there any script that will instead of having to set a time would just grab the last created one. We would like to get this automated through scheduling. Also would it be possible to delete all databases with creation dates earlier than the most current.Thanks again for your responce. |
 |
|
sodeep
Master Smack Fu Yak Hacker
7174 Posts |
Posted - 2008-04-01 : 21:47:38
|
check this one:http://www.sqlteam.com/article/database-backup-script |
 |
|
bigmac072889
Starting Member
3 Posts |
Posted - 2008-04-04 : 03:15:30
|
sodeep I just reread your post and now see how we could use what you put. I will attempt it soon and post back if it worked or not. Thanks everyone from the assistance. |
 |
|
|
|
|