Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie
Hi there,
There is an issue with role permissions that is being worked on at the moment.
If you are having trouble with access or permissions on regional forums please post here to get access: https://www.boards.ie/discussion/2058365403/you-do-not-have-permission-for-that#latest

SQL server linked servers help

  • 14-01-2014 10:19pm
    #1
    Registered Users, Registered Users 2 Posts: 1,521 ✭✭✭


    I have an exam tomorrow and have a sample question I can't answer.
    Can someone help please :(

    Its stating there is a linked server in Australia called melbourne' which is linked to a local one called Sligo. Which code would be best to get a query to execute on it.

    SELECT *
    FROM OPENROWSET ([MELBOURNE])
    , 'SELECT * FROM
    product_tbl

    OR

    SELECT *
    FROM OPENQUERY ([MELBOURNE])
    , 'SELECT * FROM
    product_tbl

    OR

    ' SELECT * FROM product_tbl')
    In (OPENQUERY([MELBOURNE])


    Any help would be greatly appreciated thanks.


Comments

  • Registered Users, Registered Users 2 Posts: 1,929 ✭✭✭GavMan


    Think your 2nd query is closest of the 3.

    Its been a while but I think it should be something like:

    SELECT * FROM OPENQUERY (MELBOURNE, 'SELECT * FROM product_tbl')


  • Closed Accounts Posts: 5,361 ✭✭✭Boskowski


    Neither of the three.

    OpenRowSet , OpenDataSource and the like are for situations where no linked server setup exists.
    Typically these statements include all the credentials to query the database, like servername, username, password etc.

    When querying a linked server you simply use the fully qualified name, for example:

    select * from [melbourne].[mydatabase].[dbo].[product_tbl]

    On top of the linked server setup you need to make sure your database user & password are lined up too.

    Of course this is too late for your exam and you probably know the answer by now, but wanted to post for everyones benefit anyway.


Advertisement