Home Forums SQL Server 2005 Backups Loading database with the latest .bak file RE: Loading database with the latest .bak file

  • you can still use the scripting or the T-SQL, but do it in an SSIS package.

    You use BIDS to create a package, add a T-SQL task, and include your T-SQL code. If you need to do some scripting, there are more programmability options in SSIS for working with files. Personally I've used VBScript for years to parse out files and order them, and choose which one to restore. To give more details, you'd have to explain more about what the files look like, are you restoring all databases, all that have bak files, how often, etc. There are a lot of details here.

    What I'd recommend is to look at Powershell if you can install that on your server. Some people might not allow an add-on like this. It's native in 2008, but must be added in 2005. (http://www.databasejournal.com/features/mssql/article.php/3681061)

    Otherwise look at VBScript and the FileSystemObject. You can use that to find all the files in the folder and then loop through them to look for the latest one (by name or modified date) for a particular database.

    You need to do some work here as it is a lot of writing to get this done for you. If oyu start working on this, you can ask specific questions about parts you don't understand.

    A few links

    http://www.sqlservercentral.com/scripts/Replication/31168/

    http://www.sqlservercentral.com/scripts/Backup+%2F+Restore/31995/