Sql-server – SQL: transfer database schema

schemaSecuritysql-server-2008

If i want to transfer schema ownership to another schema i know that i need to use something like:

ALTER SCHEMA destinationschema TRANSFER sourceschema.objectname;

But how is it different from:

ALTER AUTHORIZATION ON OBJECT::sourceschema.objectname TO destinationschema ;

Thanks in advance!

Best Answer

  • ALTER AUTHORIZATION has a more general use for changing ownership of databases, types, keys etc. There is an ENDPOINT example n this MSDN link

ALTER AUTHORIZATION can be used to change the ownership of any entity that has an owner

Transfers a securable between schemas

In this special case you've highlighted, they do the same thing, There is no difference.

I'll guess that ALTER SCHEMA was added for completeness (eg there is CREATE and DROP why not ALTER) or in preparation for other features (such as renaming a SCHEMA, say)