Change the owner of objects

  • Hi

     

    I have a database which has tables owned by a particular user 'XYZ'. Now I want to make dbo the owner of all the objects instead ox XYZ. But I'm getting an error while doing this. I'm logging in the server with the sa login and then writing the command

    sp_changeobjectowner 'Table1','sa'

    But this is not happening and instead is giving the error message

     

    Server: Msg 15001, Level 16, State 1, Procedure sp_changeobjectowner, Line 38

    Object 'Table1' does not exist or is not a valid object for this operation.

     

     

     

  • try this...

    sp_changeobjectowner 'Table1','dbo'

    "Keep Trying"

  • It gives the same error as above.

  • It is better to qualify the object name with owner name..incase if you have two objects with same name and different owners...

    exec sp_changeobjectowner @objname 'owner.object' ,  @newowner 'owner'

    exec sp_changeobjectowner 'owner.Table1','dbo'

    MohammedU
    Microsoft SQL Server MVP

  • yes it worked when I specified the owner name.

    But in this case I just had one object by this name and the owner was XYZ. then also why was it throwing a error when i was not giving the owner name.

  • If you're trying to work on an object that you do not own, you must qualify the object name with the owner.  It doesn't matter how many objects with that name there are.  In this case, you were connected as sa, but xyz owned the object. 

    Greg

    Greg

Viewing 6 posts - 1 through 5 (of 5 total)

You must be logged in to reply to this topic. Login to reply