Alter schema owner for SQL Server 2008R2 in batches
Recently I encountered a situation where after installing some enterprise software, the schema owners of all tables became something other than dbo. After googling around, here is a quick solution to batch update the owner:
First execute this query in Query Analyzer:
SELECT'ALTER SCHEMA dbo TRANSFER '+ TABLE_SCHEMA +'.'+ TABLE_NAME
FROM INFORMATION_SCHEMA.TABLES WHERE TABLE_SCHEMA ='toreplace'
No comments:
Post a Comment