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 to this problem is to use ALTER SCHEMA statement on target schema –
ALTER SCHEMA <target schema> TRANSFER <table_name>
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 –
SCHEMA dbo TRANSFER Product.Attribute