Hi there.
I have an application that calls a stored procedure which creates new databases on the fly (don't ask, legacy code). My problem is that the application user becomes the database owner of these new databases. I need to be able to execute sp_changedbowner 'sa' in the same stored procedure, immediately after the database is created to return the ownership to sa. BOL states that the current database owner should have rights to change the db owner but I have not been successful in doing so. I keep getting an error indicating that the current user does not have permissions to change the db owner. I have verified that this code is being run on the newly created db and that the current user is the dbo. I have even attempted to change the db owner directly from Query Analyzer, outside of the stored procedure.
Anyone have any ideas what I could be missing?
Thanks.
I have an application that calls a stored procedure which creates new databases on the fly (don't ask, legacy code). My problem is that the application user becomes the database owner of these new databases. I need to be able to execute sp_changedbowner 'sa' in the same stored procedure, immediately after the database is created to return the ownership to sa. BOL states that the current database owner should have rights to change the db owner but I have not been successful in doing so. I keep getting an error indicating that the current user does not have permissions to change the db owner. I have verified that this code is being run on the newly created db and that the current user is the dbo. I have even attempted to change the db owner directly from Query Analyzer, outside of the stored procedure.
Anyone have any ideas what I could be missing?
Thanks.