Skip to content

Instantly share code, notes, and snippets.

Show Gist options
  • Save kristinaconley/3d71189cb59208ad1262ecaec6b9aa98 to your computer and use it in GitHub Desktop.
Save kristinaconley/3d71189cb59208ad1262ecaec6b9aa98 to your computer and use it in GitHub Desktop.
Alter Schema to Multiple Objects
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'))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment