Rainbow Portal

 

Script to change a database owner - by Marek     6/28/2003

Here is the new script

FileName: ChangeObjectOwner.sql

Description: Contains SQL used to change Rainbow database objects owner from '\ASPNET' to 'dbo' or any other user you may want.

The script takes all user defined objects that are owned by user different than 'dbo' and changes its ownership to 'dbo'. (or the target user)

Assumptions:

The script assumes that Rainbow portal is installed with Rainbow as a database name. If the name of the database is different, change the first line of the script. The script assumes that the new user name is 'dbo'. If different user is required, change the 'dbo' name in the script (it must be a valid user in the database).

History: 06/30/2003 -- Marek Kepinski (mkepinski@impaq.com.pl)

Initial implementation.

Notes:

Ignore warning displayed be SQL Server concerning possible breaking of stored procedures due to changes of object owner.

-----Original Message-----
From: manu

Sent: Wednesday, June 25, 2003 6:45 PM

I have found a nice SQL script that may help changing owner on all objects. This is useful if you change your mind and want to go back to SQL auth after playing with integrated security (ASPNET).

SELECT 'EXEC(''sp_changeobjectowner @objname = ''''' + ltrim(u.name) + '.' +

ltrim(s.name) + '''''' + ', @newowner = dbo'')'

FROM sysobjects s, sysusers u

WHERE s.uid = u.uid AND u.name <> 'dbo'AND xtype in ('V', 'P', 'U') AND u.name not like 'INFORMATION%' order by s.name

This is not mine, I have found it there: http://www.sqlteam.com/item.asp?ItemID=1283

More on "sp_changeobjectowner" procedure: http://doc.ddart.net/mssql/sql70/sp_ca-cz_17.htm


<< Back      

powered by Rainbow with Rainbow.Zen