I'm in the process of creating a database restore script for my staging server.
Whenever I restore a database on my staging server I always restore a bak file with the latest timestamp from a specific filesystem directory. Therefore, I'd like to automate this process in my restore script.
Can you show me the T/SQL I should use to get the filename of the bak file with the latest timestamp from a specific filesystem directory?
What is the format of the filenames that you have? I ask because if they look like the following (has an ISO-style date and time embedded in the name), there is a VERY simple way to do this without using xp_CmdShell, SQLCLR, VBScripts, Powershell, or any other non-built-in method...
is pronounced ree-bar and is a Modenism for R
First step towards the paradigm shift of writing Set Based code: Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column.
If you think its expensive to hire a professional to do the job, wait until you hire an amateur. -- Red Adair
How to post code problemsHow to post performance problemsForum FAQs