Sunday, February 19, 2012

Identifying the logical files before restoring database

We have a requirement to restore the relational database from a .bak file.
This .bak file can contain more than one data file and log file. How do we
programatically determine the logical files within this bak file and restore
accordingly.
I tried using 'Restore Filelistonly', but then here i am not able to capture
the names and location of back up file and store them in a variable which ca
n
be used while restoring.
Pls adviceHi
Create a table with the same number of columns and execure RESTORE
FILELISTONLY.
"GS" <GS@.discussions.microsoft.com> wrote in message
news:523C5E6A-5E5B-493B-BBE2-73A140DB3F01@.microsoft.com...
> We have a requirement to restore the relational database from a .bak file.
> This .bak file can contain more than one data file and log file. How do we
> programatically determine the logical files within this bak file and
> restore
> accordingly.
> I tried using 'Restore Filelistonly', but then here i am not able to
> capture
> the names and location of back up file and store them in a variable which
> can
> be used while restoring.
> Pls advice
>|||Sorry, I should be more specify
CREATE TABLE #Test
(
LogicalName VARCHAR(100),
PhysicalName VARCHAR(100),
Type VARCHAR(2),
FileGroupName VARCHAR(20),
[Size]VARCHAR(100),
[MaxSize] VARCHAR(100),
)
INSERT INTO #Test EXEC('
RESTORE FILELISTONLY FROM DISK=N''c:\backupsql\dbname.bak''')
SELECT * FROM #Test
"Uri Dimant" <urid@.iscar.co.il> wrote in message
news:uDOs$0z7FHA.3200@.TK2MSFTNGP11.phx.gbl...
> Hi
> Create a table with the same number of columns and execure RESTORE
> FILELISTONLY.
>
> "GS" <GS@.discussions.microsoft.com> wrote in message
> news:523C5E6A-5E5B-493B-BBE2-73A140DB3F01@.microsoft.com...
>

No comments:

Post a Comment