Help needed to write SQL statement

  • Please see attached. We were able to successfully create a link.

    I am having a hard time writing a "Select top 100 * FROM ???? "

    Help me with the syntax please ( You may use any table shown in the catalog ) The catalog that you see is from a linked server.

    Thanks

  • mw112009 (5/14/2015)


    Please see attached. We were able to successfully create a link.

    I am having a hard time writing a "Select top 100 * FROM ???? "

    Help me with the syntax please ( You may use any table shown in the catalog ) The catalog that you see is from a linked server.

    Thanks

    select top (100) * from <linkedserver>.<database>.<schema>.<table>;

  • no did not work.. Since this was an link to an Oracle database.

    However I found it while googling...

    Select top 100 * FROM CDRQ_Moderage..[CDR].[EEG_TEXT_T]

    This works! 🙂 GOT TO HAVE 2 dots after the LINKED SERVER NAME

  • mw112009 (5/14/2015)


    no did not work.. Since this was an link to an Oracle database.

    However I found it while googling...

    Select top 100 * FROM CDRQ_Moderage..[CDR].[EEG_TEXT_T]

    This works! 🙂 GOT TO HAVE 2 dots after the LINKED SERVER NAME

    Sorry, didn't know that the linked server was to an Oracle database.

  • mw112009 (5/14/2015)


    no did not work.. Since this was an link to an Oracle database.

    However I found it while googling...

    Select top 100 * FROM CDRQ_Moderage..[CDR].[EEG_TEXT_T]

    This works! 🙂 GOT TO HAVE 2 dots after the LINKED SERVER NAME

    Really, REALLY bad idea to use 3 or 4 part naming conventions in code because linked server names can change. Instead, make a 2 part named synonym that point to the 3 or 4 part named object and use the 2 part name in your code.

    --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)

  • Jeff Moden (5/14/2015)


    mw112009 (5/14/2015)


    no did not work.. Since this was an link to an Oracle database.

    However I found it while googling...

    Select top 100 * FROM CDRQ_Moderage..[CDR].[EEG_TEXT_T]

    This works! 🙂 GOT TO HAVE 2 dots after the LINKED SERVER NAME

    Really, REALLY bad idea to use 3 or 4 part naming conventions in code because linked server names can change. Instead, make a 2 part named synonym that point to the 3 or 4 part named object and use the 2 part name in your code.

    Actually, this is a really, really good idea.

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

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