Results 1 to 3 of 3
  1. #1
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12

    Unanswered: Moving a table to a different schema

    Hi,

    We currently have all tables in the dbo schema, but for organizational reason we would like to split them up in multiple schemas and I wonder if that can be done without re-creating the tables.

    So my question is, is there a way to move a table into a different schema without re-creating it? (For those familiar with Postgres I'm looking for an equivalent to "ALTER TABLE foo SET SCHEMA newschema")

    sp_rename only allows a "one-part name" for the new name, so apparently that cannot be used.

    We (actually the customer) are using SQL Server 2005
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

  2. #2
    Join Date
    Aug 2008
    Posts
    147
    Use ALTER SCHEMA. Check this link for some examples:
    SQL Server - ALTER SCHEMA - SQL Server DBA
    ---------------------------------
    www.sqlserver-dba.com
    www.dba-db2.com

  3. #3
    Join Date
    Nov 2003
    Posts
    2,935
    Provided Answers: 12
    Ah! ALTER SCHEMA....

    I was searching for something that changed/altered the table, not the schema.

    Thanks, works fine.
    I will not read nor answer questions where the SQL code is messy and not formatted properly using [code] tags: http://www.dbforums.com/misc.php?do=bbcode#code

    Tips for good questions:

    http://tkyte.blogspot.de/2005/06/how...questions.html
    http://wiki.postgresql.org/wiki/SlowQueryQuestions
    http://catb.org/esr/faqs/smart-questions.html

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •