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 |
ranvir_2k
Posting Yak Master
180 Posts |
Posted - 2014-02-06 : 11:58:45
|
Hi all,I want to restore a full database backup taken by a SQL Server maintenance plan. I want to do this via an automated script.The full backup file name would be of the format:MyDatabase_backup_201402060153.bakUnfortunately the transaction logs for the same database are backed up to the same location as the full backup and are of the format:MyDatabase_backup_201402061600.trnLet's say the folder they are stored in is called:\\ThePathdeclare @Exe varchar(100)set @Exe = 'dir \\ThePath\MyDatabase_backup_' + convert(varchar(10),getdate(),112) + '*' I was using this code to get the full database backup name but it will return the transaction log backups as well due to the way microsoft have named transaction log backups.Is there anyway I can add the .bak to my code, so that it only returns the .bak files?i.e. it ignores the time and only looks for the date and the .bak extension.Thanks |
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
ranvir_2k
Posting Yak Master
180 Posts |
Posted - 2014-02-06 : 12:26:04
|
Many Thanks Tara! |
|
|
tkizer
Almighty SQL Goddess
38200 Posts |
|
|
|
|