What are the challenges you face when working across database platforms? Take the survey
Options

How to extract the database name from a backup file

matt.stanfordmatt.stanford Posts: 11
edited October 26, 2007 7:10PM in SQL Backup Previous Versions
I'm trying to figure out how to retrieve the database name from the header of a backup using TSQL. The issue I'm running into is that the sqlbackup procedure returns two datasets.

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?

Thanks,
-Matt

Comments

Sign In or Register to comment.