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!

quick sp_changeobjectowner script

Status
Not open for further replies.
Sep 27, 2001
179
AU
I need to change the owner of some Views after restoring a backup to a different server to user dbo.

Because of the number of views is their any way I can do this quickly rather than having to specifiy each viewname with the sp_changeobjectowner command. For example using a wildcard???

Thanks
 
You can create a script and then run that script. Run something like this.
Code:
select 'exec sp_changeobjectowner ''' + name + ''', ''dbo'''
from sysobjects
where xtype = 'V'
Run that in Query Analyzer in text mode. Take the output and run that in Query Analyzer and it will change the owner of all the views.

Denny
MCSA (2003) / MCDBA (SQL 2000)

--Anything is possible. All it takes is a little research. (Me)
[noevil]
Donate to Katrina relief
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top