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 Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Change DB Owner

Status
Not open for further replies.

dzdncnfsd

MIS
Jul 14, 2000
118
US
When I registered my SQL server in EnterpriseManager, I used NT authentication. Then I created a database and I am the owner instead of sa. I tried to fix it using "Exec sp_changedbowner 'sa', but the error message said that sa is already a user of the database, and nothing changed. Surely, there must be a way to do this????
Thanks.

Gladys Clemmer
gladys.clemmer@fifsg.com

 
have you tried changing the owners of your databases to dbo , which is pretty much the standard owner, so that you dont have a user-level owner, which can cause problems (like having two tables/etc of same name, but different owner) Karl Blessing aka kb244{fastHACK}
kblogo.jpg
 

I had a similar problem when I tried to change the database owner to sa. I got around the error by first changing the owner to another login (not already a user in the database!) and then changing the owner to sa.

exec sp_changedbowner 'login1'
go

exec sp_changedbowner 'sa'
go

I'm not certain if this will work for you but it's worth a try.
 
Try This Batch:
/************************************************************************/
/***** This batch change the object owner where the uid = UseNAme***/

select * from sysobjects where uid = user_id('UseNAme')
declare @Return int
exec @Return = sp_configure 'allow updates', '1'
SELECT @Return as 'Returned Code'
GO
reconfigure WITH OVERRIDE
GO
DECLARE @Rows int, @Error int
BEGIN TRANSACTION
update sysobjects set uid = user_id('dbo') where uid = user_id('UseNAme')
SELECT @Error = @@Error, @Rows = @@RowCount
SELECT @Rows as '#Rows'
IF @Rows > 0
BEGIN
SELECT @Rows AS '#Rows'
COMMIT TRANSACTION
END
else
BEGIN
SELECT @Error AS 'Error #'
ROLLBACK TRANSACTION
END

exec sp_configure 'allow updates', '0'
reconfigure WITH OVERRIDE
go
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top