SELECT 'ALTER SCHEMA dbo TRANSFER ' + s.Name + '.' + o.Name      FROM sys.Objects o      INNER JOIN sys.Schemas s on o.schema_id = s.schema_id      WHERE s.Name = 'custom_schema'     And (o.Type = 'U' Or o.Type = 'P' Or o.Type = 'V')

Replace custom_schema with the schema on the database
Replace dbo with the schema you want the table to have

Note: The above query only creates commands that can be used to change the schema. you will need to run the output of the above command.

Leave a Reply

Your email address will not be published. Required fields are marked *