Change object schema

Sometimes it is needed to change schema of object. Because objects are created under wrong schema.
Unfortunately it is not possible to change schema using Management Studio.

To to this you can use the code below.

[DOMAIN\byretter] is a schema which is created accidentally. "TestTable" is a table that is created under wrong schema. To correct this, we change TestTable's schema to "dbo".  Here is the code.

ALTER SCHEMA [dbo]  TRANSFER [DOMAIN\byretter].[TestTable]

No comments:

Post a Comment