CREATE SCHEMA AT LinkedServer

  • Hello all,

    I try to create a Backup Database on a linked Server using dynamic SQL. But I fail when I try to create a schema.

    EXEC ('CREATE SCHEMA common') AT [127.0.0.1]

    My Problem is that it is executed in the master database. I need it in my database, but I can't do something like

    EXEC ('CREATE SCHEMA databasename.common') AT [127.0.0.1]

    because the focus is on master or

    EXEC ('USE databasename; CREATE SCHEMA common') AT [127.0.0.1]

    because CREATE SCHEMA needs to be the first command.

    Do you have any idea?

    Greetz,

    Stefan

    ---------

    Edit: a way to solve my problem is to change the default database...

  • teutales (4/21/2010)


    EXEC ('USE databasename; CREATE SCHEMA common') AT [127.0.0.1]

    Isn't it working fine ?

    teutales (4/21/2010)


    Edit: a way to solve my problem is to change the default database...

    i think you are right here.

    -------Bhuvnesh----------
    I work only to learn Sql Server...though my company pays me for getting their stuff done;-)

  • Try this:

    EXEC ('USE databasename; EXEC(''CREATE SCHEMA common'')') AT [127.0.0.1]

    It's horrible, but it should work.

    Edited: bug in code. Should be ok now.

    -- Gianluca Sartori

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

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