Is it possible to retrieve the logical file names from a SqlBackup file ?

I am writing a generic restore program where a user selects a database they want restoring in a training system, and the process will restore from the selected sqlbackup from the live system

I need to specify the Logical_file_name in the MOVE command of the restore but this is dependent on what database is being restored. There is currently no set standard for the logical file name accross the servers and I dont want to hardcode the names...
martinb1000
0

Comments

2 comments

  • petey
    Use the RESTORE FILELISTONLY command e.g.
    EXEC master..sqlbackup '-sql "RESTORE FILELISTONLY FROM DISK = [g:\backups\AdventureWorks.sqb] " '
    
    petey
    0
  • martinb1000
    Perfect - thanks
    martinb1000
    0

Add comment

Please sign in to leave a comment.