OPENROWSET with parameters...

  • Hi,

    Seems really trivial, but I can't make it works:

    SET @NoDossier = '1315-21738'

    SELECT *

    INTO #MyTable

    FROM OPENROWSET('SQLNCLI',

    'Server=SQL2008;Database=xDManagement;Uid=user;Pwd=Passw;',

    'EXEC xDRxVGetPil_sp ''''' + @NoDossier + '''''');

    Error is: Incorrect syntax near '+'.

    can someone help me on that matter please?

    thanks for your time abd help

  • OPENROWSET - does NOT accept variables for its arguments.

    Thus you will have to use dynamic sql statements to do what you seem to need to do.

    Use this link:

    http://technet.microsoft.com/en-us/library/ms190312(SQL.90).aspx

    Scroll down to the "Remarks" section.

    Edited to add link.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • Is there any way I can call a storedProc with parameters on a linked server and put the resulting recordset on a local temporary table, like I need to do here?

  • Dominic Gagné (4/8/2011)


    Is there any way I can call a storedProc with parameters on a linked server and put the resulting recordset on a local temporary table, like I need to do here?

    Since your original post was about a specific T-SQL snippet of code, may I suggest you post what is basically a new question to a new forum so as to obtain the proper assistance.

    If everything seems to be going well, you have obviously overlooked something.

    Ron

    Please help us, help you -before posting a question please read[/url]
    Before posting a performance problem please read[/url]

  • ok, thank you very much for your assistance

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

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