How to extract the database name from a backup file
For example, with a Native SQL backup I can do:
SET @SQL = 'RESTORE HEADERONLY FROM DISK = ''' + @backupFile + '''' insert into #header EXEC (@SQL) -- Query #header to my heart's content
This of course fails when I try to something similar with master..sqlbackup because it has two different datasets that come back: one with the header information and the other with the success/failure information.
Can anyone give me some direction on how to handle this output or have an alternate way to retrieve the database name?