Transfer table from one schema to another Schema in SQL
Issue-Moving table from one schema to another schema in SQL
Issue Description- A user created a table in default schema (dbo) but as per the requirement the new table should be part of another Schema (Emp).So the new table created in dbo schema need to be moved to another Schema Emp.
Issue Solution- Table Employee created in dbo schema need to be moved in Emp Schema
Case I –When you want to move only one table from one schema to another
So below is the query
Alter Schema Emp --The Target schema Name where you are moving your table
Transfer [dbo].[employee] --The Source schema Name along with table name from where you are moving your table Employee
Case II –When you want to move all tables from one schema to another for eg. From dbo schema to Emp Schema
exec sp_MSforeachtable "ALTER SCHEMA Emp TRANSFER ?"