How to take the output of the command to a table (specially first two columns) to get logical name and physical name?

  • Hello Experts,

    Please suggest :

    How to take the output of the command to a table (specially first two columns) to get logical name and physical name

    restore filelistonly from disk = 'G:\folder1\backupfile091.bak'

    Thanks.

  • I would think first create a temp table that matches the output of that command:

    CREATE TABLE #filelistonly ( ... )

    then do this:

    INSERT INTO #filelistonly

    EXEC('restore filelistonly from disk = ''G:\folder1\backupfile091.bak'')

    Finally, of course, process that data as you would from any other table.

    SQL DBA,SQL Server MVP(07, 08, 09) "It's a dog-eat-dog world, and I'm wearing Milk-Bone underwear." "Norm", on "Cheers". Also from "Cheers", from "Carla": "You need to know 3 things about Tortelli men: Tortelli men draw women like flies; Tortelli men treat women like flies; Tortelli men's brains are in their flies".

  • ScottPletcher (11/18/2015)


    I would think first create a temp table that matches the output of that command:

    I know you said you're only interested in the first 2 columns, but Scott's dead on. You will be receiving the entire output of your command, so your temp table will have to include all the columns.

  • It worked for me. Thnx guys..

    Thanks.

Viewing 4 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply