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

  • Oh now I get it.... you want it to automagically grab the last file? http://www.sqlservercentral.com/articles/Log+Shipping/62676/ has one type of solution for this.

    Optionally, not necessarily preferably... you can use xp_Cmdshell and Dir the directory and do something clever with the output (i.e. parse out the timestamp etc.):

    Insert myFileListTable Exec master.dbo.xp_cmdshell 'dir c:\Backupfiles\'

    This blog contains a solution http://blogs.msdn.com/stuartpa/archive/2005/07/21/441468.aspx that avoids xp_cmdshell and having to parse the output.

    http://www.codecomments.com/archive352-2006-1-786972.html has some other options involving scripting.

    HTH!

    /Elisabeth

    elisabeth@sqlserverland.com
    MCITP | MCT
    http://sqlblog.com/blogs/elisabeth_redei/
    http://linkedin.com/in/elisabethredei