Creating a View in Another Database Using OpenQuery

  • Is it possible to use OpenQuery to create a view in a linked server's database? I tried it, but it didn't work for me.

  • I think this will be work:

    EXECUTE ('create view dbo.v_test as select 1 as d') AT [linked_server_name]

  • Thanks. Will this work if the linked server is NOT a SQL Server database?

  • imani_technology (5/3/2016)


    Thanks. Will this work if the linked server is NOT a SQL Server database?

    if the command is compliant with the other DBMS (mysql, oracle, etc,) then yes.

    the ODBC driver under the covers of the linked server sends the command, so if it's a valid command(and have the permissions required), you would be good to go.

    Lowell


    --help us help you! If you post a question, make sure you include a CREATE TABLE... statement and INSERT INTO... statement into that table to give the volunteers here representative data. with your description of the problem, we can provide a tested, verifiable solution to your question! asking the question the right way gets you a tested answer the fastest way possible!

  • Thanks!

  • What I'd like to know is why you're trying to backdoor something that you apparently have no privs to. Do it up front and in a forthright manner... contact the owner/DBA of that system and request they do it.

    You might also want to read your employee handbook for the company you're working for. What you're doing could be an offense where they could terminate your job with no warning.

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

  • Fortunately, this is just a proof of concept, but you are right. I followed your advice and let the Hive expert/DBA create the view. I was just being impatient.

  • imani_technology (5/3/2016)


    Fortunately, this is just a proof of concept, but you are right. I followed your advice and let the Hive expert/DBA create the view. I was just being impatient.

    Ya know... it takes a lot to admit something like that. Well done all the way around.

    --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 8 posts - 1 through 7 (of 7 total)

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