Recently we were having issues on our database server and after long efforts it was decided to change the database server. So we managed to restore the database on another s
Thanks for the tip.. Here is my update to same, where I added a crlf to output as well as put brackets around the SchemaName and ObjectName, because some of the objects had a '-' in the name and the brackets solved that naming error.
SELECT 'ALTER SCHEMA NewSchemaName TRANSFER [' + SysSchemas.Name + '].[' + DbObjects.Name + '];'
+ CHAR(13)+ CHAR(10)+ 'GO '+ CHAR(13)+ CHAR(10)
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'))