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

changing owner for each view

Status
Not open for further replies.

wrbodine

Programmer
Aug 24, 2000
302
0
0
US
Hi,

Another thread had the following, for tables. Is there something like this for views?

from another thread:

The followig script changes the table owner for all tables in the current database to 'dbo' if not already 'dbo'. The script uses the undocumented system stored procedure sp_msforeachtable.

exec sp_msforeachtable
'If left(''?'',charindex(''.'',''?'')-1)<>''[dbo]''
exec sp_changeobjectowner ''?'',''dbo'''

thanks,
Ray
 
Short answer is no, but you can do it if you want

SELECT sysobjects.name FROM sysusers INNER JOIN sysobjects ON sysusers.uid = sysobjects.uid WHERE (sysusers.uid = 1) AND (sysobjects.xtype = 'V')

That will return the object names where uid = 1 (dbo) just change the userid to the correct user you want to change. Stick those result in a cursor with sp_changeobjectowner to update to the new owner.

Easy enough
 
Thanx, that makes sense;

probably easier with the number of views we have to just change them but that could really help in the case of more of them....
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top