Database Administrators Stack Exchange is a question and answer site for database professionals who wish to improve their database skills and learn from others in the community. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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!

share|improve this question
up vote 8 down vote accepted
  • 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)

share|improve this answer
    
Thank you very much! :-) – Manjot May 10 '11 at 19:51

First try DROP SCHEMA schema_name

If the schema contains objects, the DROP statement fails.

Why?

I was trying to transfer a scheme that existed on a user account that came over when a database moved. I needed to delete the user but was getting hung-up on the schema that came with it. The schema matched the user name.

I tried the solution at this Q&A as well as at How to transfer the ownership of the dbo schema in SQL Server 2012 & Change tables from one user to another Nothing was working. I could not figure out what the problem was, The errors were, something like "can't find" I was not sure what it could not find, the account or the schema, but it did not make sense. Both the old user, and new user existed, I had already transferred db_owner and everything else except the schema to the new account.

I used the quires at List schema name and owners in sql server 2012 and I could see that the old account still had the schema of the same name no matter what I did.

I went looking for a way to find exactly what the schema was attached to. When I discovered that DROP SCHEMA only drops if there are no objects.

The schema dropped, and I was able to delete the old user.

share|improve this answer

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.