-- Find out any schemas exist not owned by dbo
select schema_name(schema_id)
, name
, command = 'ALTER SCHEMA dbo TRANSFER
[' + schema_name(schema_id) + '].[' + name + ']'
from sys.objects
where schema_name(schema_id) <> 'dbo'
and type in('U','P','V', 'FN','TF','IF')
-- To chaneg objects to the default schema
ALTER SCHEMA dbo TRANSFER
fully_qualified_object_name
-- To change the default schema
ALTER USER
xxxxx WITH DEFAULT_SCHEMA
= dbo
No comments:
Post a Comment