Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Creating database on the fly, need to change owner 1

Status
Not open for further replies.

redlam

MIS
Jun 28, 2000
218
US
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.
 
According to BOL, in SQL 7 sysadmin members AND the current DB owner can execute sp_changedbowner. But in SQL 2000, ONLY sysadmin members have permissions. What version of SQL are you using?

--James
 
Hmm. I'm using SQL 2000 but this is what my BOL says about sp_changedbowner:

Permissions
Only members of the sysadmin fixed server role OR the owner of the current database can execute sp_changedbowner.

I remember there being a service pack for BOL, perhaps I never applied it...
Thanks for the info.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top