How to move an Object to a different Schema in SQL Server

To move objects like (for example tables, views, stored procedures, functions...) between schemas you can use ALTER SCHEMA command.

In this example we will move the Table1 that is currently in dbo schema:

move_table_schema_old

First, we will create a new schema:

CREATE SCHEMA TestSchema
GO

To move the Table1 to the new TestSchema schema:

ALTER SCHEMA TestSchema
TRANSFER dbo.Table1
GO

Table1 was moved to the new TestSchema schema:

move_table_schema_new

If the post helped you, please share it:
Pin It

Leave a Reply

You can use these HTML tags

<a href="" title=""> <abbr title=""> <acronym title=""> <b> <blockquote cite=""> <cite> <code class="" title="" data-url=""> <del datetime=""> <em> <i> <q cite=""> <s> <strike> <strong> <pre class="" title="" data-url=""> <span class="" title="" data-url="">