Wednesday, March 7, 2012

How to add an existing user to a database as the owner

Is there a way to add an existing user as an "owner" of a database programmatically using SQL or a SP?
Thanks.Is there a way to add an existing user as an "owner" of a database programmatically using SQL or a SP?

Thanks.

exec sp_addrolemember N'db_owner', N'User_Name'

Replace User_name with actual user name

hope this helps.|||In addition, if that user currently, belongs to another role, you might want to drop the user from that role using sp_droprolemember|||It's actually sp_changedbowner that needs to be used if you want to change the ownership of a database.|||thanks that worked like a charm :)

No comments:

Post a Comment