retrieving out of a SQL command into variables.

  • Hi Folks,

    How can I catch the output(columns) of the following SQL

    command in a table or each column in variables?

    RESTORE FILELISTONLY

    FROM DISK='c:\temp\FlexKIDS.bak'

    I have tried the following construction, which did NOT work:

    CREATE TABLE #LIST_FILE

    (LogicalName varchar(120),

    PhysicalName varchar(500),

    L_Type char(1),

    L_FileGROUP varchar(60),

    L_size int,

    Max_size int)

    INSERT #LIST_FILE EXEC RESTORE FILELISTONLY FROM DISK='c:\temp\FlexKIDS

  • Hi,

    i use this :-

    select @load_source = "'c:\temp\FlexKIDS'"

    select @sqlstring = "RESTORE FILELISTONLY FROM DISK=" + @load_source

    insert into #list_file exec (@sqlstring)

    HTH

    Paul

  • 
    
    INSERT #List
    EXEC('RESTORE FILELISTONLY FROM DISK = ''c:\temp\FlexKIDS''')

    I suggest using the bigint data type for the size columns.

    --Jonathan



    --Jonathan

Viewing 3 posts - 1 through 2 (of 2 total)

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