OPENROWSET

  • WHT DOES THIS--
    select top 1 a.* into #t
    from openrowset('SQLNCLI', 'Server=localhost;Trusted_Connection=yes;','SET NOCOUNT ON;SET FMTONLY OFF; RESTORE HEADERONLY FROM DISK = N''C:\Stage.bak''') AS a;

    CAUSE THIS ERROR--
    Msg 11527, Level 16, State 1, Procedure sp_describe_first_result_set, Line 1 [Batch Start Line 39]
    The metadata could not be determined because statement 'RESTORE HEADERONLY FROM DISK = N'C:\Stage.bak'' does not support metadata discovery.

    AND WHAT IS NEEDED TO MAKE THAT STATEMENT WORK ?

  • Why are you using OPENROWSET to do this and not issuing the commands directly?

    The absence of evidence is not evidence of absence.
    Martin Rees

    You can lead a horse to water, but a pencil must be lead.
    Stan Laurel

  • Phil Parkin - Monday, November 26, 2018 9:39 AM

    Why are you using OPENROWSET to do this and not issuing the commands directly?

    Heh... probably because he doesn't want to take the time to figure out how to define a properly defined target table.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • Budd - Monday, November 26, 2018 9:28 AM

    WHT DOES THIS--
    select top 1 a.* into #t
    from openrowset('SQLNCLI', 'Server=localhost;Trusted_Connection=yes;','SET NOCOUNT ON;SET FMTONLY OFF; RESTORE HEADERONLY FROM DISK = N''C:\Stage.bak''') AS a;

    CAUSE THIS ERROR--
    Msg 11527, Level 16, State 1, Procedure sp_describe_first_result_set, Line 1 [Batch Start Line 39]
    The metadata could not be determined because statement 'RESTORE HEADERONLY FROM DISK = N'C:\Stage.bak'' does not support metadata discovery.

    AND WHAT IS NEEDED TO MAKE THAT STATEMENT WORK ?

    It won't work.  I've tried the same thing in the past.  You'll need to properly define a target table and then use INSERT/EXEC.

    --Jeff Moden


    RBAR is pronounced "ree-bar" and is a "Modenism" for Row-By-Agonizing-Row.
    First step towards the paradigm shift of writing Set Based code:
    ________Stop thinking about what you want to do to a ROW... think, instead, of what you want to do to a COLUMN.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

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

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