How to: Rename Schema of Existing Table

Problem

If you want to change the schema name of an existing table, you will probably look for ALTER table script to do the same. However, the real problem is you cannot change name of the schema directly neither using of the table.

Solution

Solution to this problem is to use ALTER SCHEMA statement on target schema –

ALTER SCHEMA <target schema> TRANSFER <table_name>

Example

Earlier I had table name with schema as – Product.Attribute. Here, schema name is ‘Product’ and table name is ‘Attribute’.

Later I made a decision to rename this table to dbo.Attribute with default schema as ‘dbo’.

To do this I ran following statement –

ALTER
SCHEMA dbo TRANSFER Product.Attribute

3 Comments

  1. Pingback: wamu com
  2. Heya this is a fantastic write-up. I’m going to mail this to my buddies. I came by this while browsing on aol I’ll ensue assured to come move backward. recognition for sharing.

    Reply
  3. Definitely imagine that which you stated. Your favourite reason appeared to be at the web the simplest
    factor to bear in mind of. I say to you, I certainly get annoyed even as people think
    about issues that they just don’t recognize about. You controlled to hit the nail upon the highest and also outlined out the entire thing with no need side-effects , other folks can take a signal. Will likely be back to get more. Thanks

    Reply

Leave a Comment.