Hi @moondaddy
You can change the schema of a database object by using the following script:
ALTER SCHEMA NewSchemaName TRANSFER OldSchemaName.ObjectName
The following query will generate all needed SQL scripts to complete this task:
SELECT 'ALTER SCHEMA NewSchemaName TRANSFER [' + SysSchemas.Name + '].[' + DbObjects.Name + '];'
FROM sys.Objects DbObjects
INNER JOIN sys.Schemas SysSchemas ON DbObjects.schema_id = SysSchemas.schema_id
WHERE SysSchemas.Name = 'OldSchemaName'
AND (DbObjects.Type IN ('U', 'P', 'V'))
For more details , please refer to this link: How to change schema of all tables, views and stored procedures in MSSQL
Note:Taking backups is utmost important.
Best regards,
LiHong
If the answer is the right solution, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".
Note: Please follow the steps in our Documentation to enable e-mail notifications if you want to receive the related email notification for this thread.