Last active
December 18, 2015 15:58
-
-
Save jbubriski/5807915 to your computer and use it in GitHub Desktop.
Transfer SQL Server Objects to another schema.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 = 'your_schema_name' | |
And (o.Type = 'U' Or o.Type = 'P' Or o.Type = 'V') |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
EXEC sp_MSforeachtable "ALTER SCHEMA dbo TRANSFER ? PRINT '? modified' " |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment