470,647 Members | 1,268 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 470,647 developers. It's quick & easy.

Restore Production database to Development

I have a production database with a backup job that creates files with the
naming convention dbname_db_200503291800.bak. I want to schedule a restore
job that will retire yesterdays backup. How can I write my restore statement
so that it will specify the backup file with yesterdays date.

Thanks
Jul 23 '05 #1
1 1354
Terri (te***@cybernets.com) writes:
I have a production database with a backup job that creates files with
the naming convention dbname_db_200503291800.bak. I want to schedule a
restore job that will retire yesterdays backup. How can I write my
restore statement so that it will specify the backup file with
yesterdays date.


DECLARE @filename sysname
SELECT @filename = 'dbname_db' +
convert(char(8), dateadd(DAY, -1, getdate()), 112) +
'.bak'
RESTORE DATABASE db FROM disk=@filename
--
Erland Sommarskog, SQL Server MVP, es****@sommarskog.se

Books Online for SQL Server SP3 at
http://www.microsoft.com/sql/techinf...2000/books.asp
Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by Raquel | last post: by
3 posts views Thread by Omar Vazquez | last post: by
reply views Thread by Bob Stearns | last post: by
3 posts views Thread by Bill E. | last post: by
reply views Thread by mitrofun63 | last post: by
1 post views Thread by Korara | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.